From d3867f48e7dc081eddc98f1a2111abf9c0100737 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Mon, 26 Sep 2022 12:38:18 +0000 Subject: [PATCH] [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) Signed-off-by: Ivan Elizaryev (iel) --- addons/payment/models/payment_transaction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/payment/models/payment_transaction.py b/addons/payment/models/payment_transaction.py index 97cd6732d54..24e231baf62 100644 --- a/addons/payment/models/payment_transaction.py +++ b/addons/payment/models/payment_transaction.py @@ -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)