forked from Vauxoo/stock-logistics-barcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbarcode_config.py
63 lines (56 loc) · 2.41 KB
/
barcode_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
#################################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 Julius Network Solutions SARL <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#################################################################################
import logging
from openerp.osv import fields, orm
_logger = logging.getLogger(__name__)
try:
from reportlab.graphics.barcode import getCodes
except ImportError:
_logger.warning('unable to import reportlab')
def _get_code(self, cr, uid, context=None):
"""get availble code """
return [(r, r) for r in getCodes()]
class tr_barcode_config(orm.Model):
_name = 'tr.barcode.config'
_columns = {
'res_model': fields.many2one('ir.model', 'Object',
domain=[('barcode_model', '=', True)],
required=True),
'field': fields.many2one('ir.model.fields', 'Field',
domain=[('ttype', '=', 'char')],
required=True),
'width':
fields.integer("Width",
help="Leave Blank or 0(ZERO) for default size"),
'height':
fields.integer("Height",
help="Leave Blank or 0(ZERO) for default size"),
'hr_form':
fields.boolean("Human Readable",
help="To generate Barcode In Human readable form"),
'barcode_type': fields.selection(_get_code, 'Type', required=True),
}
_sql_constraints = [
('res_model_uniq',
'unique(res_model)',
'You can have only one config by model !'),
]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: