From b3ab9604c4492615deffeda9bb6854488d1c05a2 Mon Sep 17 00:00:00 2001 From: wan Date: Thu, 26 Sep 2019 12:57:20 +0000 Subject: [PATCH] [FIX] account: reconcilciation model with amount based on regex the amount is now not always set in credit side closes odoo/odoo#37475 Signed-off-by: Quentin De Paoli (qdp) --- addons/account/models/account_reconcile_model.py | 5 +++-- .../static/src/js/reconciliation/reconciliation_model.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_reconcile_model.py b/addons/account/models/account_reconcile_model.py index 6fa63faf8c0..c56734d62f5 100644 --- a/addons/account/models/account_reconcile_model.py +++ b/addons/account/models/account_reconcile_model.py @@ -5,6 +5,7 @@ from odoo.tools import float_compare, float_is_zero from odoo.exceptions import UserError import re +from math import copysign class AccountReconcileModel(models.Model): @@ -249,7 +250,7 @@ class AccountReconcileModel(models.Model): elif self.amount_type == "regex": match = re.search(self.amount_from_label_regex, st_line.name) if match: - line_balance = float(re.sub(r'\D' + self.decimal_separator, '', match.group(1)).replace(self.decimal_separator, '.')) * (1 if balance > 0.0 else -1) + line_balance = copysign(float(re.sub(r'\D' + self.decimal_separator, '', match.group(1)).replace(self.decimal_separator, '.')) * (1 if balance > 0.0 else -1), balance) else: line_balance = 0 else: @@ -286,7 +287,7 @@ class AccountReconcileModel(models.Model): elif self.second_amount_type == "regex": match = re.search(self.second_amount_from_label_regex, st_line.name) if match: - line_balance = float(re.sub(r'\D' + self.decimal_separator, '', match.group(1)).replace(self.decimal_separator, '.')) + line_balance = copysign(float(re.sub(r'\D' + self.decimal_separator, '', match.group(1)).replace(self.decimal_separator, '.')), remaining_balance) else: line_balance = 0 else: diff --git a/addons/account/static/src/js/reconciliation/reconciliation_model.js b/addons/account/static/src/js/reconciliation/reconciliation_model.js index d1331087cdc..2854ac4760b 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_model.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_model.js @@ -1243,6 +1243,7 @@ var StatementModel = BasicModel.extend({ matching = matching[1].replace(new RegExp('\\D' + values.decimal_separator, 'g'), ''); matching = matching.replace(values.decimal_separator, '.'); amount = parseFloat(matching); + amount = line.balance.amount > 0 ? amount : -amount; } break; case 'fixed':