From a1d6c2d6317fd3cbc9af0060c14e4281ce63e11f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 27 Sep 2016 09:41:05 +0200 Subject: [PATCH] [FIX] account: check exchange rate An issue occurs in the following situation: - Define a currency exchange rate at day 1 and day 2 - Create an invoice at day 1, and calculate the taxes. Do not set an invoice date! - Validate the invoice at day 2 The exchange rate for taxes is the rate at day 1, while the exchange rate for other amounts is the rate at day 2. There is actually no way to know what was the rate applied for the taxes at invoice validation. There are two solutions: - recompute the taxes at validation - force the user to set an invoice date and recompute manually the taxes The first solution might have unexpected effects, therefore the second solution is applied. Fixes #13473 opw-688517 --- addons/account/account_invoice.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 97c4685ea52..580e033e8f3 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -807,11 +807,20 @@ class account_invoice(models.Model): ctx = dict(self._context, lang=inv.partner_id.lang) + company_currency = inv.company_id.currency_id if not inv.date_invoice: + # FORWARD-PORT UP TO SAAS-6 + if inv.currency_id != company_currency and inv.tax_line: + raise except_orm( + _('Warning!'), + _('No invoice date!' + '\nThe invoice currency is not the same than the company currency.' + ' An invoice date is required to determine the exchange rate to apply. Do not forget to update the taxes!' + ) + ) inv.with_context(ctx).write({'date_invoice': fields.Date.context_today(self)}) date_invoice = inv.date_invoice - company_currency = inv.company_id.currency_id # create the analytical lines, one move line per invoice line iml = inv._get_analytic_lines() # check if taxes are all computed