Merge pull request #5236 from expsa/fix_exp_budget_check

[FIX] exp_budget_check: singlton error
This commit is contained in:
abdurrahman-saber 2025-11-05 13:59:24 +02:00 committed by GitHub
commit abbab6ece5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 15 deletions

View File

@ -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):