[MIG] barcodes: Simplify selection fields overrides

This commit is contained in:
Tanguy Charlier
2016-06-07 17:43:35 +02:00
parent 93fc313065
commit a1a8d6d44f
4 changed files with 16 additions and 32 deletions
+11 -16
View File
@@ -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)
+2 -6
View File
@@ -1,21 +1,17 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import sets
from odoo import models
from odoo import models, fields
from odoo.tools.translate import _
class BarcodeRule(models.Model):
_inherit = 'barcode.rule'
def _get_type_selection(self):
types = sets.Set(super(BarcodeRule, self)._get_type_selection())
types.update([
type = fields.Selection(selection_add=[
('weight', _('Weighted Product')),
('price', _('Priced Product')),
('discount', _('Discounted Product')),
('client', _('Client')),
('cashier', _('Cashier'))
])
return list(types)
+1 -5
View File
@@ -2,7 +2,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
import sets
from openerp import models, fields, api, _
@@ -11,12 +10,9 @@ _logger = logging.getLogger(__name__)
class barcode_rule(models.Model):
_inherit = 'barcode.rule'
def _get_type_selection(self):
types = sets.Set(super(barcode_rule, self)._get_type_selection())
types.update([
type = fields.Selection(selection_add=[
('credit', _('Credit Card'))
])
return list(types)
class pos_mercury_payment_data(models.Model):
+2 -5
View File
@@ -1,18 +1,15 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, _
from odoo import models, fields, _
class BarcodeRule(models.Model):
_inherit = 'barcode.rule'
def _get_type_selection(self):
types = set(super(BarcodeRule, self)._get_type_selection())
types.update([
type = fields.Selection(selection_add=[
('weight', _('Weighted Product')),
('location', _('Location')),
('lot', _('Lot')),
('package', _('Package'))
])
return list(types)