Merge pull request #5236 from expsa/fix_exp_budget_check
[FIX] exp_budget_check: singlton error
This commit is contained in:
commit
abbab6ece5
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue