[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) <qdp@openerp.com>
This commit is contained in:
wan
2019-09-27 09:19:38 +00:00
parent 85cf47fc92
commit b3ab9604c4
2 changed files with 4 additions and 2 deletions
@@ -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:
@@ -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':