From 3b4560cf4270ca21189d40e639f78091ca2d5219 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 13 Jun 2016 17:11:56 +0200 Subject: [PATCH] [FIX] account: multiple journal items to fix in full batch reconciling In a batch reconciliation of journal items, it could happen that multiple journal items in a foreign currency required the creation of an exchange entry `aml_to_balance_currency |= aml` But the statement `aml.matched_debit_ids[0] or aml.matched_credit_ids[0]` requires a single browse record (singleton) to work The partial reconciliation is supposed to be the same for all the journal items to fix, we can therefore safely do `aml = aml_to_balance_currency[0]` to overcome this issue. In addition, in this condition, the full reconcile must be skipped to avoid passing multiple times in the `create_exchange_rate_entry` method (which is called in the method `create` of `account.partial.reconcile` This has been reviewed by qdp. opw-680044 --- addons/account/models/account_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 43bd2ffd97d..924738d7d5b 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -934,10 +934,10 @@ class AccountMoveLine(models.Model): if aml.currency_id and aml.currency_id == currency: total_amount_currency += aml.amount_currency if currency and aml_to_balance_currency: - aml = aml_to_balance_currency + aml = aml_to_balance_currency[0] #eventually create journal entries to book the difference due to foreign currency's exchange rate that fluctuates partial_rec = aml.credit and aml.matched_debit_ids[0] or aml.matched_credit_ids[0] - aml_id, partial_rec_id = partial_rec.create_exchange_rate_entry(aml, 0.0, total_amount_currency, currency, maxdate) + aml_id, partial_rec_id = partial_rec.with_context(skip_full_reconcile_check=True).create_exchange_rate_entry(aml_to_balance_currency, 0.0, total_amount_currency, currency, maxdate) @api.multi def remove_move_reconcile(self):