From 567ade56df66e1726a98177d9bec63f3f7b6cacc Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 5 May 2015 17:47:30 +0200 Subject: [PATCH] [FIX] account: import invoices wizard currency amount Within the 'import invoices' wizard in bank statements (addons/account/wizard/account_statement_from_invoice.py) Prevent currency rate differences when the statement currency is within the company currency (and therefore the debit/credit fields are already within the currency of the statement) opw-631895 Closes #6504 --- .../wizard/account_statement_from_invoice.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/account_voucher/wizard/account_statement_from_invoice.py b/addons/account_voucher/wizard/account_statement_from_invoice.py index 41d3560e278..362cb516e7c 100644 --- a/addons/account_voucher/wizard/account_statement_from_invoice.py +++ b/addons/account_voucher/wizard/account_statement_from_invoice.py @@ -68,8 +68,12 @@ class account_statement_from_invoice_lines(osv.osv_memory): amount = -line.credit if line.amount_currency: - amount = currency_obj.compute(cr, uid, line.currency_id.id, - statement.currency.id, line.amount_currency, context=ctx) + if line.company_id.currency_id.id != statement.currency.id: + # In the specific case where the company currency and the statement currency are the same + # the debit/credit field already contains the amount in the right currency. + # We therefore avoid to re-convert the amount in the currency, to prevent Gain/loss exchanges + amount = currency_obj.compute(cr, uid, line.currency_id.id, + statement.currency.id, line.amount_currency, context=ctx) elif (line.invoice and line.invoice.currency_id.id <> statement.currency.id): amount = currency_obj.compute(cr, uid, line.invoice.currency_id.id, statement.currency.id, amount, context=ctx)