diff options
| author | Tanguy Charlier <tac@odoo.com> | 2016-06-06 13:21:38 +0200 |
|---|---|---|
| committer | Tanguy Charlier <tac@odoo.com> | 2016-06-07 17:43:35 +0200 |
| commit | a1a8d6d44f2d16700d8a92675b9f2e5f4668c2e2 (patch) | |
| tree | de99286272ac5af47a21650c754eee711fd2d813 /addons/barcodes/models | |
| parent | 93fc3130659dc706e70546cf61f34cb906d6499b (diff) | |
[MIG] barcodes: Simplify selection fields overrides
Diffstat (limited to 'addons/barcodes/models')
| -rw-r--r-- | addons/barcodes/models/barcodes.py | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/addons/barcodes/models/barcodes.py b/addons/barcodes/models/barcodes.py index 494e47bfad5..08482581bb5 100644 --- a/addons/barcodes/models/barcodes.py +++ b/addons/barcodes/models/barcodes.py @@ -66,7 +66,7 @@ class BarcodeNomenclature(models.Model): else: return False - + # Returns a valid zero padded ean13 from an ean prefix. the ean prefix must be a string. def sanitize_ean(self, ean): ean = ean[0:13] @@ -169,25 +169,20 @@ class BarcodeRule(models.Model): _name = 'barcode.rule' _order = 'sequence asc' - @api.model - def _encoding_selection_list(self): - return [ - ('any', _('Any')), - ('ean13', 'EAN-13'), - ('ean8', 'EAN-8'), - ('upca', 'UPC-A'), - ] - - def _get_type_selection(self): - return [('alias', _('Alias')), ('product', _('Unit Product'))] - - _type_selection = lambda self: self._get_type_selection() 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') + encoding = fields.Selection([ + ('any', _('Any')), + ('ean13', 'EAN-13'), + ('ean8', 'EAN-8'), + ('upca', 'UPC-A'), + ], string='Encoding', required=True, default='any', help='This rule will apply only if the barcode is encoded with the specified encoding') + type = fields.Selection([ + ('alias', _('Alias')), + ('product', _('Unit Product')) + ], 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) |
