[FIX] account: payment reference exact match without spaces

Cherry pick of 6317e47409f066312f1f5517b0be9ed386235397 failed

The spaces should not be important in a structured reference.
Also, we should not have to include the second batch as that batch
(previously the first) was intended to match the payment reference.
By including it, we may have too much false positives proposed in the
widget and even worse: auto reconciled.

closes odoo/odoo#39820

Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
This commit is contained in:
fw-bot
2019-11-12 12:19:18 +00:00
committed by wan
parent 74c8c61d6f
commit 70d61dafa1
@@ -501,7 +501,7 @@ class AccountReconcileModel(models.Model):
(
move.invoice_payment_ref IS NOT NULL
AND
TRIM(move.invoice_payment_ref) = TRIM(st_line.name)
regexp_replace(move.invoice_payment_ref, '\s+', '', 'g') = regexp_replace(st_line.name, '\s+', '', 'g')
) AS payment_reference_flag
FROM account_bank_statement_line st_line
LEFT JOIN account_journal journal ON journal.id = st_line.journal_id
@@ -566,7 +566,7 @@ class AccountReconcileModel(models.Model):
(
move.invoice_payment_ref IS NOT NULL
AND
TRIM(move.invoice_payment_ref) = TRIM(st_line.name)
regexp_replace(move.invoice_payment_ref, '\s+', '', 'g') = regexp_replace(st_line.name, '\s+', '', 'g')
)
)
)
@@ -794,7 +794,7 @@ class AccountReconcileModel(models.Model):
break
# Needed to handle check on total residual amounts.
if first_batch_candidates or first_batch_candidates_proposed or second_batch_candidates or second_batch_candidates_proposed or model._check_rule_propositions(line, available_candidates):
if first_batch_candidates or first_batch_candidates_proposed or model._check_rule_propositions(line, available_candidates):
results[line.id]['model'] = model
# Add candidates to the result.