[FIX] account_invoice: residual of invoices in foreign currencies

If a line of the invoice move was in a foreign currency
but its residual amount in this foreign currency was 0,
the `amount_residual` (in company currency) was used,
instead of the `amount_residual_currency`, which
is the residual amount in this foreign currency.

This was due to the fall back with the `and / or` statement.
Using `if / else` instead solves the issue.

This could lead to issues when the residual amount
in the foreign currency was 0, but the residual amount
in the company currency was 0.01, due to the exchange rate
loss.
This commit is contained in:
Nicolas Martinelli 2015-05-05 18:01:30 +02:00 committed by Denis Ledoux
parent 2e3fdf3794
commit 4392289745
1 changed files with 1 additions and 1 deletions

View File

@ -131,7 +131,7 @@ class account_invoice(models.Model):
continue
# Get the correct line residual amount
if line.currency_id == self.currency_id:
line_amount = line.currency_id and line.amount_residual_currency or line.amount_residual
line_amount = line.amount_residual_currency if line.currency_id else line.amount_residual
else:
from_currency = line.company_id.currency_id.with_context(date=line.date)
line_amount = from_currency.compute(line.amount_residual, self.currency_id)