Skip to content

Commit

Permalink
[FIX] account_customer_wallet: Always write something to computed field
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
  • Loading branch information
carmenbianca committed Sep 29, 2023
1 parent dac0f02 commit b6f49b3
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions account_customer_wallet/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,14 @@ def _customer_wallet_balance_depends(self):
@api.depends(lambda self: self._customer_wallet_balance_depends())
@api.depends_context("company")
def _compute_customer_wallet_balance(self):
if not self.ids:
return True
wallet_account_id = self.env.company.customer_wallet_account_id
if not wallet_account_id or not self.ids:
# Always assign a value in a compute method.
self.write({"customer_wallet_balance": 0.0})
return

all_partner_families = {}
all_partner_ids = set()
wallet_account_id = self.env.company.customer_wallet_account_id
if not wallet_account_id:
# No wallet account defined in the current context
for partner in self:
partner.customer_wallet_balance = 0.0
return

# we split the calculation in two part to optimize it
# because the call of get_all_partners_in_family take time
Expand Down

0 comments on commit b6f49b3

Please sign in to comment.