[FIX] account: Fix regex matching rule in reconciliation model
Before:
Suppose 'invoices 2018/0002 and 2018/0003' that becomes '2018000220180003' after
REGEXP_REPLACE(st_line.name, '[^0-9]', '', 'g').
'2018000220180003' ~ '20180002' match: OK
'2018000220180003' ~ '2018' match: NOT OK
'2018000220180003' ~ '' match: NOT OK
After this commit:
move.name/move.ref giving an empty string are filtered out.
'invoices 2018/0002 and 2018/0003'
becomes ' 20180002 20180003' after REGEXP_REPLACE(st_line.name, '[^(0-9|\s)]', '', 'g')
and becomes {"",2018001,2018002} after the regexp_split_to_array.
Then, the matching is now done by a comparison instead of a pattern matching between the move
and this array of potential candidates.
'20180002' = ANY({"",2018001,2018002}) match: OK
'2018' = ANY({"",2018001,2018002}) not match: OK
'' is filtered out: OK
closes odoo/odoo#28962
This commit is contained in:
@@ -392,14 +392,17 @@ class AccountReconcileModel(models.Model):
|
||||
aml.date_maturity AS aml_date_maturity,
|
||||
aml.amount_residual AS aml_amount_residual,
|
||||
aml.amount_residual_currency AS aml_amount_residual_currency,
|
||||
CASE WHEN
|
||||
REGEXP_REPLACE(st_line.name, '[^0-9]', '', 'g') ~ REGEXP_REPLACE(move.name, '[^0-9]', '', 'g')
|
||||
OR (
|
||||
move.ref IS NOT NULL
|
||||
AND
|
||||
REGEXP_REPLACE(st_line.name, '[^0-9]', '', 'g') ~ REGEXP_REPLACE(move.ref, '[^0-9]', '', 'g')
|
||||
)
|
||||
THEN TRUE ELSE FALSE END AS communication_flag
|
||||
CASE WHEN TRIM(REGEXP_REPLACE(move.name, '[^0-9]', '', 'g')) = '' THEN FALSE
|
||||
ELSE
|
||||
TRIM(REGEXP_REPLACE(move.name, '[^0-9]', '', 'g'))
|
||||
= ANY(regexp_split_to_array(REGEXP_REPLACE(st_line.name, '[^(0-9|\s)]', '', 'g'), '\s+'))
|
||||
OR (
|
||||
move.ref IS NOT NULL
|
||||
AND TRIM(REGEXP_REPLACE(move.ref, '[^0-9]', '', 'g')) != ''
|
||||
AND TRIM(REGEXP_REPLACE(move.ref, '[^0-9]', '', 'g'))
|
||||
= ANY(regexp_split_to_array(REGEXP_REPLACE(st_line.name, '[^(0-9|\s)]', '', 'g'), '\s+'))
|
||||
)
|
||||
END AS communication_flag
|
||||
FROM account_bank_statement_line st_line
|
||||
LEFT JOIN account_journal journal ON journal.id = st_line.journal_id
|
||||
LEFT JOIN jnl_precision ON jnl_precision.journal_id = journal.id
|
||||
@@ -427,13 +430,18 @@ class AccountReconcileModel(models.Model):
|
||||
AND CASE WHEN line_partner.partner_id != 0 THEN
|
||||
aml.partner_id = line_partner.partner_id
|
||||
ELSE
|
||||
(
|
||||
REGEXP_REPLACE(st_line.name, '[^0-9]', '', 'g') ~ REGEXP_REPLACE(move.name, '[^0-9]', '', 'g')
|
||||
OR (
|
||||
move.ref IS NOT NULL
|
||||
AND
|
||||
REGEXP_REPLACE(st_line.name, '[^0-9]', '', 'g') ~ REGEXP_REPLACE(move.ref, '[^0-9]', '', 'g')
|
||||
)
|
||||
(
|
||||
CASE WHEN TRIM(REGEXP_REPLACE(move.name, '[^0-9]', '', 'g')) = '' THEN FALSE
|
||||
ELSE
|
||||
TRIM(REGEXP_REPLACE(move.name, '[^0-9]', '', 'g'))
|
||||
= ANY(regexp_split_to_array(REGEXP_REPLACE(st_line.name, '[^(0-9|\s)]', '', 'g'), '\s+'))
|
||||
OR (
|
||||
move.ref IS NOT NULL
|
||||
AND TRIM(REGEXP_REPLACE(move.ref, '[^0-9]', '', 'g')) != ''
|
||||
AND TRIM(REGEXP_REPLACE(move.ref, '[^0-9]', '', 'g'))
|
||||
= ANY(regexp_split_to_array(REGEXP_REPLACE(st_line.name, '[^(0-9|\s)]', '', 'g'), '\s+'))
|
||||
)
|
||||
END
|
||||
)
|
||||
END
|
||||
|
||||
|
||||
Reference in New Issue
Block a user