From b98a0e6959345ee45701ecf832cc72e186d84c7a Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Thu, 14 Nov 2019 17:57:31 +0100 Subject: [PATCH] adds extra logic to determine the group separator --- base_gs1_barcode/models/gs1_barcode.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/base_gs1_barcode/models/gs1_barcode.py b/base_gs1_barcode/models/gs1_barcode.py index f844f9cd19a9..0978d0b89815 100644 --- a/base_gs1_barcode/models/gs1_barcode.py +++ b/base_gs1_barcode/models/gs1_barcode.py @@ -83,9 +83,15 @@ def normalize_date(datestring): return fields.Date.to_string(date) # Prefix and Group Separator + # Search if the barcode contains the \x1D group separator already, + # and then use it. Some scanners are able to pass this group separator, + # and others are not able. If a user works with both devices, + # this is becomes the most effective mechanism to ensure co-existence. + if '\x1D' in barcode_string: + separator = '\x1D' + else: + separator = self.env.user.gs1_barcode_separator or '\x1D' prefix = self.env.user.gs1_barcode_prefix or '' - separator = self.env.user.gs1_barcode_separator or '\x1D' - if not barcode_string.startswith(prefix): raise exceptions.ValidationError( _('Could not decode barcode : wrong prefix - the code should '