6
set_to_zero_form = """<?xml version="1.0"?>
7
<form string="Reset cashbox">
8
<label string="Are you sure you want to reset this cashbox ?"/>
13
confirm_setting_zero_fields = {}
15
def _set_to_zero(self,cr,uid,data,context):
16
pool= pooler.get_pool(cr.dbname)
17
cashmove_ref = pool.get('lunch.cashmove')
18
cr.execute("select user_cashmove, box,sum(amount) from lunch_cashmove where active= 't' and box in (%s) group by user_cashmove, box"%','.join(map(str,data['ids'])))
20
cr.execute("update lunch_cashmove set active = 'f' where active= 't' and box in (%s)"%','.join(map(str,data['ids'])))
21
## to_unactive= {}.fromkeys([r[0] for r in cr.fetchall]).keys()
23
## cashmove_ref.write(cr,uid,to_unactive,{'active':False})
25
for (user_id,box_id,amount) in res:
26
cashmove_ref.create(cr,uid,{'name': 'Summary for user'+ str(user_id),
28
'user_cashmove': user_id,
35
class cashbox_set_to_zero(wizard.interface):
41
'result':{'type' : 'form',
42
'arch' : set_to_zero_form,
43
'fields' : confirm_setting_zero_fields,
44
'state' : [('end', 'Cancel'),('zero', 'Set to Zero') ]},
48
'actions' : [_set_to_zero],
49
'result' : {'type' : 'state', 'state' : 'end'}
53
cashbox_set_to_zero('lunch.cashbox.clean')