diff --git a/addons/barcodes/data/barcodes_data.xml b/addons/barcodes/data/barcodes_data.xml
index 69ac657e432..55b8caa83e3 100644
--- a/addons/barcodes/data/barcodes_data.xml
+++ b/addons/barcodes/data/barcodes_data.xml
@@ -1,6 +1,5 @@
-
-
+
Default Nomenclature
@@ -13,5 +12,4 @@
any
.*
-
-
+
diff --git a/addons/barcodes/models/barcode_events_mixin.py b/addons/barcodes/models/barcode_events_mixin.py
index 383e622c0a1..b8913dfdb09 100644
--- a/addons/barcodes/models/barcode_events_mixin.py
+++ b/addons/barcodes/models/barcode_events_mixin.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-from openerp import models, fields, api
+from odoo import models, fields, api
class BarcodeEventsMixin(models.AbstractModel):
""" Mixin class for objects reacting when a barcode is scanned in their form views
diff --git a/addons/barcodes/models/barcodes.py b/addons/barcodes/models/barcodes.py
index a288fd2e55c..494e47bfad5 100644
--- a/addons/barcodes/models/barcodes.py
+++ b/addons/barcodes/models/barcodes.py
@@ -1,11 +1,8 @@
import logging
import re
-import openerp
-from openerp import tools, models, fields, api
-from openerp.osv import fields, osv
-from openerp.tools.translate import _
-from openerp.exceptions import ValidationError
+from odoo import tools, models, fields, api, _
+from odoo.exceptions import ValidationError
_logger = logging.getLogger(__name__)
@@ -17,18 +14,13 @@ UPC_EAN_CONVERSIONS = [
('always','Always'),
]
-class barcode_nomenclature(osv.osv):
+class BarcodeNomenclature(models.Model):
_name = 'barcode.nomenclature'
- _columns = {
- 'name': fields.char('Nomenclature Name', size=32, required=True, help='An internal identification of the barcode nomenclature'),
- 'rule_ids': fields.one2many('barcode.rule','barcode_nomenclature_id','Rules', help='The list of barcode rules'),
- 'upc_ean_conv': fields.selection(UPC_EAN_CONVERSIONS, 'UPC/EAN Conversion', required=True,
- help='UPC Codes can be converted to EAN by prefixing them with a zero. This setting determines if a UPC/EAN barcode should be automatically converted in one way or another when trying to match a rule with the other encoding.'),
- }
- _defaults = {
- 'upc_ean_conv': 'always',
- }
+ name = fields.Char(string='Nomenclature Name', size=32, required=True, help='An internal identification of the barcode nomenclature')
+ rule_ids = fields.One2many('barcode.rule', 'barcode_nomenclature_id', string='Rules', help='The list of barcode rules')
+ upc_ean_conv = fields.Selection(UPC_EAN_CONVERSIONS, string='UPC/EAN Conversion', required=True, default='always',
+ help="UPC Codes can be converted to EAN by prefixing them with a zero. This setting determines if a UPC/EAN barcode should be automatically converted in one way or another when trying to match a rule with the other encoding.")
# returns the checksum of the ean13, or -1 if the ean has not the correct length, ean must be a string
def ean_checksum(self, ean):
@@ -173,7 +165,7 @@ class barcode_nomenclature(osv.osv):
return parsed_result
-class barcode_rule(models.Model):
+class BarcodeRule(models.Model):
_name = 'barcode.rule'
_order = 'sequence asc'
@@ -186,26 +178,18 @@ class barcode_rule(models.Model):
('upca', 'UPC-A'),
]
- @api.model
def _get_type_selection(self):
return [('alias', _('Alias')), ('product', _('Unit Product'))]
- _columns = {
- 'name': fields.char('Rule Name', size=32, required=True, help='An internal identification for this barcode nomenclature rule'),
- 'barcode_nomenclature_id': fields.many2one('barcode.nomenclature','Barcode Nomenclature'),
- 'sequence': fields.integer('Sequence', help='Used to order rules such that rules with a smaller sequence match first'),
- 'encoding': fields.selection('_encoding_selection_list','Encoding',required=True,help='This rule will apply only if the barcode is encoded with the specified encoding'),
- 'type': fields.selection('_get_type_selection','Type', required=True),
- 'pattern': fields.char('Barcode Pattern', size=32, help="The barcode matching pattern", required=True),
- 'alias': fields.char('Alias',size=32,help='The matched pattern will alias to this barcode', required=True),
- }
+ _type_selection = lambda self: self._get_type_selection()
- _defaults = {
- 'type': 'product',
- 'pattern': '.*',
- 'encoding': 'any',
- 'alias': "0",
- }
+ name = fields.Char(string='Rule Name', size=32, required=True, help='An internal identification for this barcode nomenclature rule')
+ barcode_nomenclature_id = fields.Many2one('barcode.nomenclature', string='Barcode Nomenclature')
+ sequence = fields.Integer(string='Sequence', help='Used to order rules such that rules with a smaller sequence match first')
+ encoding = fields.Selection(_encoding_selection_list, string='Encoding', required=True, default='any', help='This rule will apply only if the barcode is encoded with the specified encoding')
+ type = fields.Selection(_type_selection, string='Type', required=True, default='product')
+ 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')
@@ -221,5 +205,3 @@ class barcode_rule(models.Model):
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 '.*' ?"))
-
-
diff --git a/addons/barcodes/views/barcodes_templates.xml b/addons/barcodes/views/barcodes_templates.xml
index 16ace99c063..4370533d4ca 100644
--- a/addons/barcodes/views/barcodes_templates.xml
+++ b/addons/barcodes/views/barcodes_templates.xml
@@ -1,6 +1,5 @@
-
-
+
@@ -13,5 +12,4 @@
-
-
+
diff --git a/addons/barcodes/views/barcodes_view.xml b/addons/barcodes/views/barcodes_view.xml
index b288f4a2839..3f97324313a 100644
--- a/addons/barcodes/views/barcodes_view.xml
+++ b/addons/barcodes/views/barcodes_view.xml
@@ -1,6 +1,5 @@
-
-
+
Barcode Nomenclatures
@@ -82,5 +81,4 @@
-
-
+