From 8469fe2eace33019f7b82ecf83a3648358342498 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 28 Sep 2016 09:45:14 +0200 Subject: [PATCH] [FIX] account: exchange rate date The fields `amount_total_company_signed` and `amount_untaxed_signed` are always converted using the exchange rate of today. opw-688838 --- addons/account/models/account_invoice.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index eb3d5cde5e3..8b9d07a27ec 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -39,7 +39,7 @@ class AccountInvoice(models.Model): _order = "date_invoice desc, number desc, id desc" @api.one - @api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount', 'currency_id', 'company_id') + @api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount', 'currency_id', 'company_id', 'date_invoice') def _compute_amount(self): self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line_ids) self.amount_tax = sum(line.amount for line in self.tax_line_ids) @@ -47,8 +47,9 @@ class AccountInvoice(models.Model): amount_total_company_signed = self.amount_total amount_untaxed_signed = self.amount_untaxed if self.currency_id and self.currency_id != self.company_id.currency_id: - amount_total_company_signed = self.currency_id.compute(self.amount_total, self.company_id.currency_id) - amount_untaxed_signed = self.currency_id.compute(self.amount_untaxed, self.company_id.currency_id) + currency_id = self.currency_id.with_context(date=self.date_invoice) + amount_total_company_signed = currency_id.compute(self.amount_total, self.company_id.currency_id) + amount_untaxed_signed = currency_id.compute(self.amount_untaxed, self.company_id.currency_id) sign = self.type in ['in_refund', 'out_refund'] and -1 or 1 self.amount_total_company_signed = amount_total_company_signed * sign self.amount_total_signed = self.amount_total * sign