Merge pull request #375 from expsa/dev_odex25_accounting

Dev odex25 accounting
This commit is contained in:
Mostafa 2024-07-23 23:26:45 +03:00 committed by GitHub
commit 776d99ca57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 13 deletions

View File

@ -134,19 +134,20 @@ class AccountMove(models.Model):
def button_draft(self):
res = super(AccountMove, self).button_draft()
if self.is_check:
date = fields.Date.from_string(self.date)
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
fields.Date.from_string(x.date_from) <= date <= fields.Date.from_string(x.date_to))
amount = budget_lines.confirm
amount -= (line.price_subtotal + line.price_tax)
budget_lines.write({'confirm': amount})
for rec in self:
if rec.is_check:
date = fields.Date.from_string(rec.date)
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
fields.Date.from_string(x.date_from) <= date <= fields.Date.from_string(x.date_to))
amount = budget_lines.confirm
amount -= (line.price_subtotal + line.price_tax)
budget_lines.write({'confirm': amount})
return res
def action_budget(self):