[IMP] account: Merge the opening_control and closing_control flags in cash_control
[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, context.get('active_ids', []) or [], context=context)
19
20             bank_statements = [record.cash_register_id for record in records if record.cash_register_id]
21
22             if not bank_statements:
23                 raise osv.except_osv(_('Error!'),
24                                      _("There is no cash register for this PoS Session"))
25
26             return self._run(cr, uid, ids, bank_statements, context=context)
27         else:
28             return super(PosBox, self).run(cr, uid, ids, context=context)
29
30 class PosBoxIn(PosBox):
31     _inherit = 'cash.box.in'
32
33 class PosBoxOut(PosBox):
34     _inherit = 'cash.box.out'
35