From 9335fed9fecdf411c4e266be58302a5021e14106 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 5 May 2015 18:06:24 +0200 Subject: [PATCH] [FIX] account: debit/credit values for move lines in foreign currencies When the target currency is the company currency, there is no need to re-compute the debit/credit amounts of the move lines, since these debit/credit values already contains the amount of the move line within the company currency. Avoiding the recomputation prevents gain/loss during currencies exchanges opw-631748 opw-632133 opw-631895 --- addons/account/account_move_line.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 2e5cdce5e84..4ed1219caaa 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -825,12 +825,17 @@ class account_move_line(osv.osv): total_amount_currency_str = rml_parser.formatLang(total_amount, currency_obj=line_currency) ret_line['credit_currency'] = actual_credit ret_line['debit_currency'] = actual_debit - ctx = context.copy() - if target_date: - ctx.update({'date': target_date}) - total_amount = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, total_amount, context=ctx) - actual_debit = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, actual_debit, context=ctx) - actual_credit = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, actual_credit, context=ctx) + if target_currency == company_currency: + actual_debit = debit + actual_credit = credit + total_amount = debit or credit + else: + ctx = context.copy() + if target_date: + ctx.update({'date': target_date}) + total_amount = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, total_amount, context=ctx) + actual_debit = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, actual_debit, context=ctx) + actual_credit = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, actual_credit, context=ctx) amount_str = rml_parser.formatLang(actual_debit or actual_credit, currency_obj=target_currency) total_amount_str = rml_parser.formatLang(total_amount, currency_obj=target_currency)