[IMP] touchscreen pos, usability improvements
[odoo/odoo.git] / addons / point_of_sale / wizard / pos_box.py
1 #!/usr/bin/env python
2
3 from tools.translate import _
4 from osv import osv, fields
5 from account.wizard.pos_box import CashBox
6
7 class PosBox(CashBox):
8     _register = False
9
10     def run(self, cr, uid, ids, context=None):
11         if not context:
12             context = dict()
13
14         active_model = context.get('active_model', False) or False
15         active_ids = context.get('active_ids', []) or []
16
17         if active_model == 'pos.session':
18             records = self.pool.get(active_model).browse(cr, uid, active_ids, context=context)
19             bank_statements = [record.cash_register_id for record in records if record.cash_register_id]
20
21             if not bank_statements:
22                 raise osv.except_osv(_('Error!'),
23                                      _("There is no cash register for this PoS Session"))
24
25             return self._run(cr, uid, ids, bank_statements, context=context)
26         else:
27             return super(PosBox, self).run(cr, uid, ids, context=context)
28
29 class PosBoxIn(PosBox):
30     _inherit = 'cash.box.in'
31
32     def _compute_values_for_statement_line(self, cr, uid, box, record, context=None):
33         values = super(PosBoxIn, self)._compute_values_for_statement_line(cr, uid, box, record, context=context)
34
35         active_model = context.get('active_model', False) or False
36         active_ids = context.get('active_ids', []) or []
37
38         if active_model == 'pos.session':
39             session = self.pool.get(active_model).browse(cr, uid, active_ids, context=context)[0]
40             values['ref'] = session.name
41
42         return values
43
44
45 class PosBoxOut(PosBox):
46     _inherit = 'cash.box.out'
47
48     def _compute_values_for_statement_line(self, cr, uid, box, record, context=None):
49         values = super(PosBoxOut, self)._compute_values_for_statement_line(cr, uid, box, record, context=context)
50
51         active_model = context.get('active_model', False) or False
52         active_ids = context.get('active_ids', []) or []
53
54         if active_model == 'pos.session':
55             session = self.pool.get(active_model).browse(cr, uid, active_ids, context=context)[0]
56             values['ref'] = session.name
57
58         return values