From eabb144fc6d7f025d036b2ed699d61c709fe9e8c Mon Sep 17 00:00:00 2001 From: oco-odoo Date: Fri, 1 Oct 2021 14:12:51 +0000 Subject: [PATCH] [IMP] account: reconciliation models: make use of the fact currency_id is always set on move lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In older versions, currency_id was left empty on move lines in domestic currency (as well as amount_currency and amount_residual_currency). It's not the case anymore, so we can simplify the code a little bit. closes odoo/odoo#77260 closes odoo/odoo#77801 Related: odoo/enterprise#21354 Related: odoo/enterprise#21437 Signed-off-by: William André (wan) --- addons/account/models/account_reconcile_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_reconcile_model.py b/addons/account/models/account_reconcile_model.py index 10d9341e3e9..729a4fb8411 100644 --- a/addons/account/models/account_reconcile_model.py +++ b/addons/account/models/account_reconcile_model.py @@ -803,13 +803,13 @@ class AccountReconcileModel(models.Model): candidates, priorities = self._filter_candidates(candidates, aml_ids_to_exclude, reconciled_amls_ids) st_line_currency = st_line.foreign_currency_id or st_line.currency_id - candidate_currencies = set(candidate['aml_currency_id'] or st_line.company_id.currency_id.id for candidate in candidates) + candidate_currencies = set(candidate['aml_currency_id'] for candidate in candidates) kept_candidates = candidates if candidate_currencies == {st_line_currency.id}: kept_candidates = [] sum_kept_candidates = 0 for candidate in candidates: - candidate_residual = candidate['aml_amount_residual_currency'] if candidate['aml_currency_id'] else candidate['aml_amount_residual'] + candidate_residual = candidate['aml_amount_residual_currency'] if st_line_currency.compare_amounts(candidate_residual, -st_line.amount_residual) == 0: # Special case: the amounts are the same, submit the line directly.