[FIX] account: Trim all space chars in reconciliation match
PostgresSQL TRIM function does not trim line return and other space characters
that are not white space.
For references having a non trimmed character regexp_split_to_array would create an array
with an empty element. Such element could be matched to a counterpart with no numerics in
the reference.
TRIM(' \n001') => '\n001'
regexp_split_to_array('\n001') => {"", "001"}
By replacing the TRIM function by a substring using a regexp we
also remove the other space characters such as tab and line return.
closes odoo/odoo#44026
X-original-commit: 93f63c331781179fc6b81c14563a97b1d6a9b300
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
@@ -447,7 +447,7 @@ class AccountReconcileModel(models.Model):
|
||||
for rule in self:
|
||||
# N.B: 'communication_flag' is there to distinguish invoice matching through the number/reference
|
||||
# (higher priority) from invoice matching using the partner (lower priority).
|
||||
query = '''
|
||||
query = r'''
|
||||
SELECT
|
||||
%s AS sequence,
|
||||
%s AS model_id,
|
||||
@@ -465,22 +465,22 @@ class AccountReconcileModel(models.Model):
|
||||
(
|
||||
aml.name IS NOT NULL
|
||||
AND
|
||||
TRIM(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g')) != ''
|
||||
substring(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*') != ''
|
||||
AND
|
||||
regexp_split_to_array(TRIM(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g')),'\s+')
|
||||
&& regexp_split_to_array(TRIM(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g')), '\s+')
|
||||
regexp_split_to_array(substring(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
|
||||
&& regexp_split_to_array(substring(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
|
||||
)
|
||||
OR
|
||||
regexp_split_to_array(TRIM(REGEXP_REPLACE(move.name, '[^0-9|^\s]', '', 'g')),'\s+')
|
||||
&& regexp_split_to_array(TRIM(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g')), '\s+')
|
||||
regexp_split_to_array(substring(REGEXP_REPLACE(move.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
|
||||
&& regexp_split_to_array(substring(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
|
||||
OR
|
||||
(
|
||||
move.ref IS NOT NULL
|
||||
AND
|
||||
TRIM(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g')) != ''
|
||||
substring(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*') != ''
|
||||
AND
|
||||
regexp_split_to_array(TRIM(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g')),'\s+')
|
||||
&& regexp_split_to_array(TRIM(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g')), '\s+')
|
||||
regexp_split_to_array(substring(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
|
||||
&& regexp_split_to_array(substring(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
|
||||
) AS communication_flag,
|
||||
-- Determine a matching or not with the statement line communication using the move.invoice_payment_ref.
|
||||
(
|
||||
@@ -524,28 +524,28 @@ class AccountReconcileModel(models.Model):
|
||||
(
|
||||
line_partner.partner_id = 0
|
||||
AND
|
||||
TRIM(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g')) != ''
|
||||
substring(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*') != ''
|
||||
AND
|
||||
(
|
||||
(
|
||||
aml.name IS NOT NULL
|
||||
AND
|
||||
TRIM(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g')) != ''
|
||||
substring(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*') != ''
|
||||
AND
|
||||
regexp_split_to_array(TRIM(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g')),'\s+')
|
||||
&& regexp_split_to_array(TRIM(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g')), '\s+')
|
||||
regexp_split_to_array(substring(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
|
||||
&& regexp_split_to_array(substring(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
|
||||
)
|
||||
OR
|
||||
regexp_split_to_array(TRIM(REGEXP_REPLACE(move.name, '[^0-9|^\s]', '', 'g')),'\s+')
|
||||
&& regexp_split_to_array(TRIM(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g')), '\s+')
|
||||
regexp_split_to_array(substring(REGEXP_REPLACE(move.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
|
||||
&& regexp_split_to_array(substring(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
|
||||
OR
|
||||
(
|
||||
move.ref IS NOT NULL
|
||||
AND
|
||||
TRIM(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g')) != ''
|
||||
substring(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*') != ''
|
||||
AND
|
||||
regexp_split_to_array(TRIM(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g')),'\s+')
|
||||
&& regexp_split_to_array(TRIM(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g')), '\s+')
|
||||
regexp_split_to_array(substring(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
|
||||
&& regexp_split_to_array(substring(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
|
||||
)
|
||||
OR
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user