From 7a5146cc676ec1cbfd359782862a4db224103ed8 Mon Sep 17 00:00:00 2001 From: "Nasreddin Boulif (bon)" Date: Mon, 9 Aug 2021 15:30:35 +0000 Subject: [PATCH] [FIX] account: parse sequence with date before year 2000 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to repodruce: - Install 'Accounting' module - Set user language to French - Create journal entry - Set a date before 2000. Example : 01/01/1999 - Insert some journal items - Save the journal entry Issue: Error message is raised : ```The journal entry cannot be saved : "The Date (01/01/1999) doesn't match the Numéro (OPD/1999/01/0001).``` Cause: Incomplete regex: parsing only years who begin with 20 or 21. https://github.com/odoo/odoo/commit/26a43f23ec2b2490aec0731e25568703729581f0#diff-67b6f8b23970c1b18fc5e7f82b7585ad82e7bace885cdd78274837a4876a6a9fL24-R25 Solution: Add 19 to regex to allow years like '19XX'. opw-2616575 closes odoo/odoo#75755 X-original-commit: da9a2fab230c07cd0ce069bc7832ffcce4b8e988 Signed-off-by: William André (wan) --- addons/account/models/sequence_mixin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/sequence_mixin.py b/addons/account/models/sequence_mixin.py index bf84c468579..231448b3668 100644 --- a/addons/account/models/sequence_mixin.py +++ b/addons/account/models/sequence_mixin.py @@ -21,8 +21,8 @@ class SequenceMixin(models.AbstractModel): _sequence_field = "name" _sequence_date_field = "date" _sequence_index = False - _sequence_monthly_regex = r'^(?P.*?)(?P((?<=\D)|(?<=^))((20|21)\d{2}|(\d{2}(?=\D))))(?P\D*?)(?P(0[1-9]|1[0-2]))(?P\D+?)(?P\d*)(?P\D*?)$' - _sequence_yearly_regex = r'^(?P.*?)(?P((?<=\D)|(?<=^))((20|21)?\d{2}))(?P\D+?)(?P\d*)(?P\D*?)$' + _sequence_monthly_regex = r'^(?P.*?)(?P((?<=\D)|(?<=^))((19|20|21)\d{2}|(\d{2}(?=\D))))(?P\D*?)(?P(0[1-9]|1[0-2]))(?P\D+?)(?P\d*)(?P\D*?)$' + _sequence_yearly_regex = r'^(?P.*?)(?P((?<=\D)|(?<=^))((19|20|21)?\d{2}))(?P\D+?)(?P\d*)(?P\D*?)$' _sequence_fixed_regex = r'^(?P.*?)(?P\d{0,9})(?P\D*?)$' sequence_prefix = fields.Char(compute='_compute_split_sequence', store=True)