From daf93196e3bfd4cb847bd9344430eb565ac5d22d Mon Sep 17 00:00:00 2001 From: Cyril VINH-TUNG Date: Thu, 8 Jun 2023 14:04:08 -1000 Subject: [PATCH] [FIX] Practical amount should not be computed if Budgetary position has no account --- account_budget_oca_analytic_tag/models/account_budget.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/account_budget_oca_analytic_tag/models/account_budget.py b/account_budget_oca_analytic_tag/models/account_budget.py index f50e8a0b..d5d85397 100644 --- a/account_budget_oca_analytic_tag/models/account_budget.py +++ b/account_budget_oca_analytic_tag/models/account_budget.py @@ -30,7 +30,7 @@ def _compute_practical_amount(self): ) result = self.env.cr.fetchone()[0] or 0.0 - else: + elif line.general_budget_id.account_ids: self.env.cr.execute( """ SELECT SUM(credit) - SUM(debit) @@ -53,6 +53,8 @@ def _compute_practical_amount(self): ), ) result = self.env.cr.fetchone()[0] + else: + result = 0.0 line.practical_amount = result @api.constrains("general_budget_id", "analytic_account_id", "analytic_tag_id")