diff options
| author | Adrian Torres <adt@odoo.com> | 2018-12-12 09:46:02 +0000 |
|---|---|---|
| committer | Adrian Torres <adt@odoo.com> | 2019-07-05 09:04:45 +0000 |
| commit | 9e71d57d11faf3fabd00b8a09188e9d4f9808c63 (patch) | |
| tree | 4dfda85fb19bf1f68954cadbd8a39bbb582ef775 /addons/barcodes/models | |
| parent | f5676fabea8a09f5702d00e75f3cf55f01ed5b22 (diff) | |
[REM] *: remove calls to `api.one` and adapt code
Adapt all code that was using `api.one` to recordset-style method and
remove any and all calls to `api.one` in preparation for its removal.
Diffstat (limited to 'addons/barcodes/models')
| -rw-r--r-- | addons/barcodes/models/barcodes.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/addons/barcodes/models/barcodes.py b/addons/barcodes/models/barcodes.py index c7fd1292b92..5f82c963d2c 100644 --- a/addons/barcodes/models/barcodes.py +++ b/addons/barcodes/models/barcodes.py @@ -188,17 +188,17 @@ class BarcodeRule(models.Model): pattern = fields.Char(string='Barcode Pattern', size=32, help="The barcode matching pattern", required=True, default='.*') alias = fields.Char(string='Alias', size=32, default='0', help='The matched pattern will alias to this barcode', required=True) - @api.one @api.constrains('pattern') def _check_pattern(self): - p = self.pattern.replace("\\\\", "X").replace("\{", "X").replace("\}", "X") - findall = re.findall("[{]|[}]", p) # p does not contain escaped { or } - if len(findall) == 2: - if not re.search("[{][N]*[D]*[}]", p): - raise ValidationError(_("There is a syntax error in the barcode pattern ") + self.pattern + _(": braces can only contain N's followed by D's.")) - elif re.search("[{][}]", p): - raise ValidationError(_("There is a syntax error in the barcode pattern ") + self.pattern + _(": empty braces.")) - elif len(findall) != 0: - raise ValidationError(_("There is a syntax error in the barcode pattern ") + self.pattern + _(": a rule can only contain one pair of braces.")) - elif p == '*': - raise ValidationError(_(" '*' is not a valid Regex Barcode Pattern. Did you mean '.*' ?")) + for rule in self: + p = rule.pattern.replace("\\\\", "X").replace("\{", "X").replace("\}", "X") + findall = re.findall("[{]|[}]", p) # p does not contain escaped { or } + if len(findall) == 2: + if not re.search("[{][N]*[D]*[}]", p): + raise ValidationError(_("There is a syntax error in the barcode pattern ") + rule.pattern + _(": braces can only contain N's followed by D's.")) + elif re.search("[{][}]", p): + raise ValidationError(_("There is a syntax error in the barcode pattern ") + rule.pattern + _(": empty braces.")) + elif len(findall) != 0: + raise ValidationError(_("There is a syntax error in the barcode pattern ") + rule.pattern + _(": a rule can only contain one pair of braces.")) + elif p == '*': + raise ValidationError(_(" '*' is not a valid Regex Barcode Pattern. Did you mean '.*' ?")) |
