Merge pull request #453 from expsa/dev_odex25_accounting

Dev odex25 accounting
This commit is contained in:
Moutaz Muhammad 2024-07-31 22:15:15 +03:00 committed by GitHub
commit 3b9d3f5427
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View File

@ -51,10 +51,10 @@ class CrossoveredBudgetLines(models.Model):
reserved_percent = fields.Float(related='crossovered_budget_id.reserved_percent', string='Reserved Percent')
reserved_amount = fields.Float(string='Reserved Amount', readonly=True, compute='_compute_reserved_amount')
pull_out = fields.Monetary(string='Pull Out', compute='_compute_pull_out',
help=_('Amount of money that has been pulled out'),store=True)
help=_('Amount of money that has been pulled out'),store=False)
provide = fields.Float(string='Provide', compute='_compute_provide',
help=_('Amount of money that has been provided'),store=True)
help=_('Amount of money that has been provided'),store=False)
remain = fields.Float(string='Remain of Christening', compute='_compute_remain',help=_('Amount of money that has been remained'))
above_remain = fields.Float(string='Exceed Amount', compute='_compute_remain',
@ -70,7 +70,7 @@ class CrossoveredBudgetLines(models.Model):
year_end = fields.Boolean(compute="get_year_end")
final_amount = fields.Float(string='Final Amount', compute='_compute_final_amount',
help=_('Final amount of money that has been provided'),store=True)
help=_('Final amount of money that has been provided'),store=False)
reserve = fields.Float(string='Reserve Amount', compute='_compute_reserve',
help=_('Total amount of reserved purchase orders'))
@ -106,16 +106,22 @@ class CrossoveredBudgetLines(models.Model):
@api.depends('from_operation_ids')
def _compute_pull_out(self):
for line in self:
operations = self.env['budget.operations'].search(
[('from_budget_line_id', '=', line.id), ('state', '=', 'confirmed')])
pull_out = sum(op.amount + op.purchase_remind for op in
line.from_operation_ids.filtered(lambda x: x.state == 'confirmed') if
operations.filtered(lambda x: x.state == 'confirmed') if
op.operation_type == 'transfer' or op.operation_type == 'decrease')
line.pull_out = pull_out if line.planned_amount < 0 else pull_out * -1
@api.depends('to_operation_ids')
def _compute_provide(self):
for line in self:
operations = self.env['budget.operations'].search(
[('to_budget_line_id', '=', line.id), ('state', '=', 'confirmed')])
provide = sum(op.amount + op.purchase_remind for op in
line.to_operation_ids.filtered(lambda x: x.state == 'confirmed') if
operations.filtered(lambda x: x.state == 'confirmed') if
op.operation_type == 'transfer' or op.operation_type == 'increase')
line.provide = provide * -1 if line.planned_amount < 0 else provide

View File

@ -77,6 +77,4 @@ class CrossoveredBudgetLines(models.Model):
(line.id, date_from, date_to,))
budget_confirm_amount = self.env.cr.fetchone()[0] or 0.0
line.pull_out = abs(pull_out)
line.provide = abs(provide)
line.budget_confirm_amount = budget_confirm_amount