Skip to content

Commit

Permalink
[FIX] account_global_discount: Fix singleton error in _compute_amount
Browse files Browse the repository at this point in the history
For reducing diff, we rename the method and call it record per record.

Fixes OCA#788
  • Loading branch information
pedrobaeza committed May 17, 2024
1 parent 4ae9a07 commit 95f6edd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion account_global_discount/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Account Global Discount',
'version': '12.0.1.0.1',
'version': '12.0.1.0.2',
'category': 'Accounting',
'author': 'Tecnativa,'
'Odoo Community Association (OCA)',
Expand Down
16 changes: 10 additions & 6 deletions account_global_discount/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,7 @@ def _onchange_global_discount_ids(self):
"""Trigger global discount lines to recompute all"""
return self._onchange_invoice_line_ids()

@api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount',
'tax_line_ids.amount_rounding', 'currency_id', 'company_id',
'date_invoice', 'type',
'invoice_global_discount_ids', 'global_discount_ids')
def _compute_amount(self):
super()._compute_amount()
def _compute_amount_one(self):
if not self.invoice_global_discount_ids:
return
round_curr = self.currency_id.round
Expand All @@ -152,6 +147,15 @@ def _compute_amount(self):
self.amount_total_signed = self.amount_total * sign
self.amount_untaxed_signed = amount_untaxed_signed * sign

@api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount',
'tax_line_ids.amount_rounding', 'currency_id', 'company_id',
'date_invoice', 'type',
'invoice_global_discount_ids', 'global_discount_ids')
def _compute_amount(self):
super()._compute_amount()
for record in self:
record._compute_amount_one()

def get_taxes_values(self):
"""Override this computation for adding global discount to taxes."""
round_curr = self.currency_id.round
Expand Down

0 comments on commit 95f6edd

Please sign in to comment.