[IMP] account: reconciliation models: make use of the fact currency_id is always set on move lines

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) <wan@odoo.com>
This commit is contained in:
oco-odoo
2021-10-05 15:41:03 +00:00
committed by william-andre
parent 2df6107cd7
commit eabb144fc6
@@ -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.