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")