[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
This commit is contained in:
Nicolas Martinelli
2016-09-28 09:55:00 +02:00
parent 40bce50ddb
commit 8469fe2eac
+4 -3
View File
@@ -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