diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 1b6cc337c80..0633511b86d 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -337,7 +337,7 @@ class AccountMove(models.Model): line.currency_id = new_currency self.line_ids._onchange_currency() - self._recompute_dynamic_lines() + self._recompute_dynamic_lines(recompute_tax_base_amount=True) @api.onchange('invoice_payment_ref') def _onchange_invoice_payment_ref(self): @@ -422,7 +422,7 @@ class AccountMove(models.Model): 'tag_ids': [(6, 0, tax_vals['tag_ids'])], } - def _recompute_tax_lines(self): + def _recompute_tax_lines(self, recompute_tax_base_amount=False): ''' Compute the dynamic tax lines of the journal entry. :param lines_map: The line_ids dispatched by type containing: @@ -562,6 +562,8 @@ class AccountMove(models.Model): if not tax_line and not taxes_map_entry['grouping_dict']: continue + elif tax_line and recompute_tax_base_amount: + tax_line.tax_base_amount = tax_base_amount elif tax_line and not taxes_map_entry['grouping_dict']: # The tax line is no longer used, drop it. self.line_ids -= tax_line @@ -853,7 +855,7 @@ class AccountMove(models.Model): self.invoice_payment_ref = new_terms_lines[-1].name or '' self.invoice_date_due = new_terms_lines[-1].date_maturity - def _recompute_dynamic_lines(self, recompute_all_taxes=False): + def _recompute_dynamic_lines(self, recompute_all_taxes=False, recompute_tax_base_amount=False): ''' Recompute all lines that depend of others. For example, tax lines depends of base lines (lines having tax_ids set). This is also the case of cash rounding @@ -873,6 +875,8 @@ class AccountMove(models.Model): # Compute taxes. if recompute_all_taxes: invoice._recompute_tax_lines() + if recompute_tax_base_amount: + invoice._recompute_tax_lines(recompute_tax_base_amount=True) if invoice.is_invoice(include_receipts=True):