From b6f49b30d01a33c2014fbed4c2cc7fd9e6f33936 Mon Sep 17 00:00:00 2001 From: Carmen Bianca BAKKER Date: Fri, 29 Sep 2023 14:10:06 +0200 Subject: [PATCH] [FIX] account_customer_wallet: Always write something to computed field Signed-off-by: Carmen Bianca BAKKER --- account_customer_wallet/models/res_partner.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/account_customer_wallet/models/res_partner.py b/account_customer_wallet/models/res_partner.py index 5c578f319..6b1201d90 100644 --- a/account_customer_wallet/models/res_partner.py +++ b/account_customer_wallet/models/res_partner.py @@ -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