[FIX] account: badly formatted reconciliation proposition

When a reconciliation proposition's amount is computed from a regex, we
cannnot be sure the regex captured something. If it didn't we don't want
to display a badly formatted line so we set the amount to 0.

closes odoo/odoo#38870

X-original-commit: 111495795b6cdc53312096078033804dbbfe57f2
Signed-off-by: Cedric Snauwaert (csn) <csn@openerp.com>
This commit is contained in:
wan
2019-10-16 11:51:27 +00:00
committed by fw-bot
parent eaa094285e
commit e00532ffb9
2 changed files with 3 additions and 3 deletions
@@ -1238,11 +1238,11 @@ var StatementModel = BasicModel.extend({
break;
case 'regex':
var matching = line.st_line.name.match(new RegExp(values.amount_from_label_regex))
amount = null;
amount = 0;
if (matching && matching.length == 2) {
matching = matching[1].replace(new RegExp('\\D' + values.decimal_separator, 'g'), '');
matching = matching.replace(values.decimal_separator, '.');
amount = parseFloat(matching);
amount = parseFloat(matching) || 0;
amount = line.balance.amount > 0 ? amount : -amount;
}
break;
@@ -296,7 +296,7 @@
<tr t-if="line.display !== false" t-attf-class="mv_line #{line.already_paid ? ' already_reconciled' : ''} #{line.__invalid ? 'invalid' : ''} #{line.is_tax ? 'is_tax' : ''}" t-att-data-line-id="line.id" t-att-data-selected="selected">
<td class="cell_account_code"><t t-esc="line.account_code"/>&#8203;</td> <!-- zero width space to make empty lines the height of the text -->
<td class="cell_due_date">
<t t-if="typeof(line.id) != 'number' &amp;&amp; line.amount">
<t t-if="typeof(line.id) != 'number' &amp;&amp; line.id">
<span class="badge badge-secondary">New</span>
</t>
<t t-else="" t-esc="line.date_maturity || line.date"/>