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