From 56d92213b82d417e48cb5a3432eb57dcba706b6e Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 27 Apr 2016 16:44:46 +0200 Subject: [PATCH] [FIX] account: reconciled with forced `amount_currency` This is possible to create bank statements forcing the amount in the foreign currency, along with the bank account currency, and therefore to force the foreign currency rate. In such a case, when reconciling the journal items, the currency rate conversion must not be done against the currency rates written in database, in the rates records, at that date, but with the rate that was forced in the bank statement. opw-676048 --- addons/account/models/account_move.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 28722d53e0b..91d1a80bace 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -253,12 +253,16 @@ class AccountMoveLine(models.Model): amount += sign_partial_line * partial_line.amount #getting the date of the matched item to compute the amount_residual in currency - date = partial_line.credit_move_id.date if partial_line.debit_move_id == line else partial_line.debit_move_id.date if line.currency_id: if partial_line.currency_id and partial_line.currency_id == line.currency_id: amount_residual_currency += sign_partial_line * partial_line.amount_currency else: - amount_residual_currency += sign_partial_line * line.company_id.currency_id.with_context(date=date).compute(partial_line.amount, line.currency_id) + if line.balance and line.amount_currency: + rate = line.amount_currency / line.balance + else: + date = partial_line.credit_move_id.date if partial_line.debit_move_id == line else partial_line.debit_move_id.date + rate = line.currency_id.with_context(date=date).rate + amount_residual_currency += sign_partial_line * line.currency_id.round(partial_line.amount * rate) #computing the `reconciled` field. As we book exchange rate difference on each partial matching, #we can only check the amount in company currency