summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorTanguy Charlier <tac@odoo.com>2016-06-06 13:21:38 +0200
committerTanguy Charlier <tac@odoo.com>2016-06-07 17:43:35 +0200
commita1a8d6d44f2d16700d8a92675b9f2e5f4668c2e2 (patch)
treede99286272ac5af47a21650c754eee711fd2d813 /addons
parent93fc3130659dc706e70546cf61f34cb906d6499b (diff)
[MIG] barcodes: Simplify selection fields overrides
Diffstat (limited to 'addons')
-rw-r--r--addons/barcodes/models/barcodes.py27
-rw-r--r--addons/point_of_sale/models/barcode_rule.py8
-rw-r--r--addons/pos_mercury/models/pos_mercury.py6
-rw-r--r--addons/stock/models/barcode.py7
4 files changed, 16 insertions, 32 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)
diff --git a/addons/point_of_sale/models/barcode_rule.py b/addons/point_of_sale/models/barcode_rule.py
index ffbf0b384b8..9fab9caa69a 100644
--- a/addons/point_of_sale/models/barcode_rule.py
+++ b/addons/point_of_sale/models/barcode_rule.py
@@ -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)
diff --git a/addons/pos_mercury/models/pos_mercury.py b/addons/pos_mercury/models/pos_mercury.py
index 6bf92d7ba1a..2244d258816 100644
--- a/addons/pos_mercury/models/pos_mercury.py
+++ b/addons/pos_mercury/models/pos_mercury.py
@@ -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):
diff --git a/addons/stock/models/barcode.py b/addons/stock/models/barcode.py
index 701ce3fc54d..99b88475e47 100644
--- a/addons/stock/models/barcode.py
+++ b/addons/stock/models/barcode.py
@@ -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)