[IMP] some refactoring due to changes in the web client
[odoo/odoo.git] / addons / point_of_sale / res_users.py
1
2 import math
3
4 from openerp.osv import osv, fields
5
6 import openerp.addons.product.product
7
8
9 class res_users(osv.osv):
10     _inherit = 'res.users'
11     _columns = {
12         'ean13' : fields.char('EAN13', size=13, help="BarCode"),
13         'pos_config' : fields.many2one('pos.config', 'Default Point of Sale', domain=[('state', '=', 'active')]),
14     }
15
16     def _check_ean(self, cr, uid, ids, context=None):
17         return all(
18             openerp.addons.product.product.check_ean(user.ean13) == True
19             for user in self.browse(cr, uid, ids, context=context)
20         )
21
22     def edit_ean(self, cr, uid, ids, context):
23         return {
24             'name': "Edit EAN",
25             'type': 'ir.actions.act_window',
26             'view_type': 'form',
27             'view_mode': 'form',
28             'res_model': 'pos.ean_wizard',
29             'target' : 'new',
30             'view_id': False,
31             'context':context,
32         }
33
34     _constraints = [
35         (_check_ean, "Error: Invalid ean code", ['ean13'],),
36     ]
37