[FIX] payment: handle reference with special regexp characters
Method `_compute_reference` computes unique reference for a transaction. If reference from `account.move`'s `payment_reference` was never used, the method just returns that reference. Othwerwise it adds a counter. The latter requires to make a regular expression to count records with the same prefix. However, if the prefix has special regexp characters (e.g. `+++INV/2020/666+++`), then we have to escape the characters first. This is what this commit does. opw-2994126 closes odoo/odoo#101201 X-original-commit: 6c513d43eba8c58171b0fb632d0ac82b28aa9e7d Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com> Signed-off-by: Ivan Elizaryev (iel) <iel@odoo.com>
This commit is contained in:
@@ -357,7 +357,7 @@ class PaymentTransaction(models.Model):
|
||||
# For instance, the prefix 'example' is a valid match for the existing references
|
||||
# 'example', 'example-1' and 'example-ref', in that order. Trusting the order to infer
|
||||
# the sequence number would lead to a collision with 'example-1'.
|
||||
search_pattern = re.compile(rf'^{prefix}{separator}(\d+)$')
|
||||
search_pattern = re.compile(rf'^{re.escape(prefix)}{separator}(\d+)$')
|
||||
max_sequence_number = 0 # If no match is found, start the sequence with this reference
|
||||
for existing_reference in same_prefix_references:
|
||||
search_result = re.search(search_pattern, existing_reference)
|
||||
|
||||
Reference in New Issue
Block a user