From 424c3c727b82ee7466f677505690da8b90f7ef60 Mon Sep 17 00:00:00 2001 From: alt-odoo Date: Fri, 6 Aug 2021 21:01:20 +0000 Subject: [PATCH] [FIX] account: prevent ValueError when applying reconciliation rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we have a reconciliation model having a rule using a regex, we are extracting the balance from the label, but we should not raise an error in case the regex is matching an incorrect float value, and just set a zero balance instead. closes odoo/odoo#74853 X-original-commit: a8d65794cfe6c7c64e03b13b8cbaa52a67b25b70 Signed-off-by: William André (wan) Signed-off-by: Alex Tuyls --- addons/account/models/account_reconcile_model.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_reconcile_model.py b/addons/account/models/account_reconcile_model.py index 29dcc0ce3db..435f3049d44 100644 --- a/addons/account/models/account_reconcile_model.py +++ b/addons/account/models/account_reconcile_model.py @@ -337,8 +337,11 @@ class AccountReconcileModel(models.Model): match = re.search(line.amount_string, st_line.payment_ref) if match: sign = 1 if residual_balance > 0.0 else -1 - extracted_balance = float(re.sub(r'\D' + self.decimal_separator, '', match.group(1)).replace(self.decimal_separator, '.')) - balance = copysign(extracted_balance * sign, residual_balance) + try: + extracted_balance = float(re.sub(r'\D' + self.decimal_separator, '', match.group(1)).replace(self.decimal_separator, '.')) + balance = copysign(extracted_balance * sign, residual_balance) + except ValueError: + balance = 0 else: balance = 0 else: