From 7d684c95999ea579771d54688dfe66d3705adb50 Mon Sep 17 00:00:00 2001 From: Abdurrahman Saber Date: Wed, 5 Nov 2025 13:57:56 +0200 Subject: [PATCH] [FIX] exp_budget_check: singlton error --- .../models/account_invoice.py | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/odex25_accounting/exp_budget_check/models/account_invoice.py b/odex25_accounting/exp_budget_check/models/account_invoice.py index 97d875ecb..e75f03387 100644 --- a/odex25_accounting/exp_budget_check/models/account_invoice.py +++ b/odex25_accounting/exp_budget_check/models/account_invoice.py @@ -137,21 +137,22 @@ class AccountMove(models.Model): def action_post(self): res = super(AccountMove, self).action_post() - if self.is_check: - confirm_budget = self.env['budget.confirmation'].search([('invoice_id', '=', self.id)]) - confirm_budget.write({'ref': self.name}) - for line in self.invoice_line_ids: - analytic_account_id = line.analytic_account_id - budget_post = self.env['account.budget.post'].search([]).filtered( - lambda x: line.account_id in x.account_ids) - budget_lines = analytic_account_id.crossovered_budget_line.filtered( - lambda x: x.general_budget_id in budget_post and - x.crossovered_budget_id.state == 'done' and - x.date_from <= self.invoice_date <= x.date_to) - amount = sum(budget_lines.mapped('confirm')) - amount += (line.price_subtotal + line.price_tax) - budget_lines.write({'confirm': amount}) - budget_lines.write({'reserve': abs((line.price_subtotal + line.price_tax) - budget_lines.reserve)}) + for rec in self: + if rec.is_check: + confirm_budget = self.env['budget.confirmation'].search([('invoice_id', '=', rec.id)]) + confirm_budget.write({'ref': rec.name}) + for line in rec.invoice_line_ids: + analytic_account_id = line.analytic_account_id + budget_post = self.env['account.budget.post'].search([]).filtered( + lambda x: line.account_id in x.account_ids) + budget_lines = analytic_account_id.crossovered_budget_line.filtered( + lambda x: x.general_budget_id in budget_post and + x.crossovered_budget_id.state == 'done' and + x.date_from <= rec.invoice_date <= x.date_to) + amount = sum(budget_lines.mapped('confirm')) + amount += (line.price_subtotal + line.price_tax) + budget_lines.write({'confirm': amount}) + budget_lines.write({'reserve': abs((line.price_subtotal + line.price_tax) - budget_lines.reserve)}) return res def button_draft(self):