[FIX] account: recompute base amount tax
- In a multi currency company, create an invoice with the domestic currency ($); - Add a product (500$) with taxes; - Change the currency to a foreign one (€); - The product don't change of amount but only of currency (500€); - Save the invoice, and print it. Before this commit, the base_amount_tax of the tax wasn't be updated. Note that the base_amount_tax it should be expressed in domestic currency. As this field didn't update in this case, the base_amount_tax is expressing the amount in foreign currency. As this amount is supposed to be in domestic, for the sake of the reports, it's change in currency of the invoice (in this case the foreign one), and it's shown in the report. The amount shown is not correct. Now, the base_amount_tax is recompute and setted in domestic currency. opw-2157853 closes odoo/odoo#43071 X-original-commit: 226a1155124e890d00e33968feb43b9fd6b99fa5 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user