From 1e5eca501f7213408e9061becd092cbe5cdf126c Mon Sep 17 00:00:00 2001 From: Akim Juillerat Date: Wed, 22 Jan 2020 13:55:16 +0000 Subject: [PATCH] [FIX] account: Fix matching rules reconciliation when dealing with negative amounts match_total_amount_param on account.reconciliation.model is not respected when paying a vendor bill through bank statement because the amounts from both the statement line and the move line that are used in the comparison will be negative. closes odoo/odoo#44234 X-original-commit: 1a9221584f78fc7619277c2c0e9b9659e7c80ee2 Signed-off-by: Laurent Smet --- addons/account/models/account_reconcile_model.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_reconcile_model.py b/addons/account/models/account_reconcile_model.py index 2e46ca7a737..e15d6f01809 100644 --- a/addons/account/models/account_reconcile_model.py +++ b/addons/account/models/account_reconcile_model.py @@ -657,10 +657,13 @@ class AccountReconcileModel(models.Model): if float_is_zero(total_residual - line_residual, precision_rounding=line_currency.rounding): return True - if line_residual > total_residual: - amount_percentage = (total_residual / line_residual) * 100 + line_residual_to_compare = line_residual if line_residual > 0.0 else -line_residual + total_residual_to_compare = total_residual if line_residual > 0.0 else -total_residual + + if line_residual_to_compare > total_residual_to_compare: + amount_percentage = (total_residual_to_compare / line_residual_to_compare) * 100 elif total_residual: - amount_percentage = (line_residual / total_residual) * 100 if total_residual else 0 + amount_percentage = (line_residual_to_compare / total_residual_to_compare) * 100 if total_residual_to_compare else 0.0 else: return False return amount_percentage >= self.match_total_amount_param