[FIX] account: prevent ValueError when applying reconciliation rule
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) <wan@odoo.com> Signed-off-by: Alex Tuyls <alt-odoo@users.noreply.github.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user