diff --git a/addons/lunch/__terp__.py b/addons/lunch/__terp__.py
index bc7dfcbfef7..b4fe451aac1 100644
--- a/addons/lunch/__terp__.py
+++ b/addons/lunch/__terp__.py
@@ -27,8 +27,10 @@
"category" : "Generic Modules/Others",
"init_xml": [],
"update_xml": [
- 'security/ir.model.access.csv',
- 'lunch_wizard.xml',
+ 'security/ir.model.access.csv',
+ 'wizard/lunch_order_cancel_view.xml',
+ 'wizard/lunch_order_confirm_view.xml',
+ 'wizard/lunch_cashbox_clean_view.xml',
'lunch_view.xml',
'lunch_report.xml',
#'process/lunch_process.xml'
diff --git a/addons/lunch/lunch_wizard.xml b/addons/lunch/lunch_wizard.xml
deleted file mode 100644
index 0820ae7d80c..00000000000
--- a/addons/lunch/lunch_wizard.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/lunch/wizard/__init__.py b/addons/lunch/wizard/__init__.py
index e290a2e933c..543ebdbf8dc 100644
--- a/addons/lunch/wizard/__init__.py
+++ b/addons/lunch/wizard/__init__.py
@@ -18,9 +18,8 @@
# along with this program. If not, see .
#
##############################################################################
-
-import confirm
-import cancel
-import reset_box
+import lunch_order_confirm
+import lunch_order_cancel
+import lunch_cashbox_clean
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/lunch/wizard/lunch_cashbox_clean.py b/addons/lunch/wizard/lunch_cashbox_clean.py
new file mode 100644
index 00000000000..f70e31e0507
--- /dev/null
+++ b/addons/lunch/wizard/lunch_cashbox_clean.py
@@ -0,0 +1,54 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from osv import fields, osv
+
+class lunch_cashbox_clean(osv.osv_memory):
+
+ _name = "lunch.cashbox.clean"
+ _description = "clean cashbox"
+
+ def set_to_zero(self, cr, uid, ids, context):
+ """
+ clean Cashbox. set active fields False.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List Lunch cashbox Clean’s IDs
+ @return:Dictionary {}.
+ """
+ cashmove_ref = self.pool.get('lunch.cashmove')
+ 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, context['active_ids'])))
+ res = cr.fetchall()
+ cr.execute("update lunch_cashmove set active = 'f' where active= 't' and box in (%s)" % ','.join(map(str, context['active_ids'])))
+## to_unactive= {}.fromkeys([r[0] for r in cr.fetchall]).keys()
+## print to_unactive
+## cashmove_ref.write(cr,uid,to_unactive,{'active':False})
+ for (user_id, box_id, amount) in res:
+ cashmove_ref.createcr, uid, {'name': 'Summary for user' + str(user_id),
+ 'amount': amount,
+ 'user_cashmove': user_id,
+ 'box': box_id,
+ 'active': True,
+ })
+ return {}
+
+lunch_cashbox_clean()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/lunch/wizard/lunch_cashbox_clean_view.xml b/addons/lunch/wizard/lunch_cashbox_clean_view.xml
new file mode 100644
index 00000000000..6e151dc0484
--- /dev/null
+++ b/addons/lunch/wizard/lunch_cashbox_clean_view.xml
@@ -0,0 +1,38 @@
+
+
+
+
+ lunch.cashbox.clean.form
+ lunch.cashbox.clean
+ form
+
+
+
+
+
+
+ Set CashBox to Zero
+ lunch.cashbox.clean
+ form
+ tree,form
+
+ new
+ {'record_id':active_id}
+
+
+
+
+
+
diff --git a/addons/lunch/wizard/cancel.py b/addons/lunch/wizard/lunch_order_cancel.py
similarity index 58%
rename from addons/lunch/wizard/cancel.py
rename to addons/lunch/wizard/lunch_order_cancel.py
index 1acc1535a90..91f25aa421a 100644
--- a/addons/lunch/wizard/cancel.py
+++ b/addons/lunch/wizard/lunch_order_cancel.py
@@ -18,36 +18,25 @@
# along with this program. If not, see .
#
##############################################################################
+from osv import fields, osv
-import wizard
-import netsvc
-import ir
-import pooler
-
-cancel_form = """
-"""
-
-
-cancel_fields = {
-}
-
-def _cancel(self,cr,uid,data,context):
- return pooler.get_pool(cr.dbname).get('lunch.order').lunch_order_cancel(cr,uid,data['ids'],context)
-
-class order_cancel(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type':'form', 'arch':cancel_form, 'fields':cancel_fields, 'state':[('end','No'),('cancel','Yes')]}
- },
- 'cancel': {
- 'actions': [_cancel],
- 'result': {'type':'state', 'state':'end'}
- }
- }
-order_cancel('lunch.order.cancel')
+class lunch_order_cancel(osv.osv_memory):
+ """
+ Cancel Lunch Order
+ """
+ _name = "lunch.order.cancel"
+ _description = "Cancel Order"
+
+ def cancel(self, cr, uid, ids, context):
+ """
+ Cancel cashmove entry from cashmoves and update state to draft.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List Lunch Order Cancel’s IDs
+ """
+ return self.pool.get('lunch.order').lunch_order_cancel(cr, uid, context['active_ids'], context)
+
+lunch_order_cancel()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/lunch/wizard/lunch_order_cancel_view.xml b/addons/lunch/wizard/lunch_order_cancel_view.xml
new file mode 100644
index 00000000000..c69d321b938
--- /dev/null
+++ b/addons/lunch/wizard/lunch_order_cancel_view.xml
@@ -0,0 +1,38 @@
+
+
+
+
+ lunch.order.cancel.form
+ lunch.order.cancel
+ form
+
+
+
+
+
+
+ Cancel Order
+ lunch.order.cancel
+ form
+ tree,form
+
+ new
+ {'record_id':active_id}
+
+
+
+
+
+
diff --git a/addons/lunch/wizard/confirm.py b/addons/lunch/wizard/lunch_order_confirm.py
similarity index 50%
rename from addons/lunch/wizard/confirm.py
rename to addons/lunch/wizard/lunch_order_confirm.py
index 64891098349..9b7476f40e3 100644
--- a/addons/lunch/wizard/confirm.py
+++ b/addons/lunch/wizard/lunch_order_confirm.py
@@ -19,42 +19,33 @@
#
##############################################################################
-import wizard
-import netsvc
-import ir
-import pooler
+from osv import fields, osv
-confirm_order_form = """
-
-"""
-
-confirm_order_fields = {
- 'confirm_cashbox': {'string':'Name of box', 'type':'many2one', 'required':True, 'relation':'lunch.cashbox' },
-}
-
-def _confirm(self,cr,uid,data,context):
- pool= pooler.get_pool(cr.dbname)
- order_ref = pool.get('lunch.order')
- order_ref.confirm(cr,uid,data['ids'],data['form']['confirm_cashbox'],context)
- return {}
-
-class order_confirm(wizard.interface):
- states = {
- 'init': {
- 'action':[],
- 'result':{'type' : 'form', 'arch' : confirm_order_form, 'fields' : confirm_order_fields, 'state' : [('end', 'Cancel'),('go', 'Confirm Order') ]},
- },
- 'go' : {
- 'actions' : [_confirm],
- 'result' : {'type' : 'state', 'state' : 'end'}
- },
- }
-order_confirm('lunch.order.confirm')
+class lunch_order_confirm(osv.osv_memory):
+ """
+ Confirm Lunch Order
+ """
+ _name = "lunch.order.confirm"
+ _description = "confirm Order"
+ _columns = {
+ 'confirm_cashbox':fields.many2one('lunch.cashbox', 'Name of box', required=True),
+ }
+
+ def confirm(self, cr, uid, ids, context):
+ """
+ confirm Lunch Order.Create cashmoves in launch cashmoves when state is
+ confirm in lunch order.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List Lunch Order confirm’s IDs
+ @return: Dictionary {}.
+ """
+ order_ref = self.pool.get('lunch.order')
+ for data in self.read(cr, uid, ids):
+ order_ref.confirm(cr, uid, context['active_ids'], data['confirm_cashbox'], context)
+ return {}
+lunch_order_confirm()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/lunch/wizard/lunch_order_confirm_view.xml b/addons/lunch/wizard/lunch_order_confirm_view.xml
new file mode 100644
index 00000000000..89ddd8f6153
--- /dev/null
+++ b/addons/lunch/wizard/lunch_order_confirm_view.xml
@@ -0,0 +1,40 @@
+
+
+
+
+ lunch.order.confirm.form
+ lunch.order.confirm
+ form
+
+
+
+
+
+
+ Confirm Order
+ lunch.order.confirm
+ form
+ tree,form
+
+ new
+ {'record_id':active_id}
+
+
+
+
+
+
diff --git a/addons/lunch/wizard/reset_box.py b/addons/lunch/wizard/reset_box.py
deleted file mode 100644
index 83999fc3ba0..00000000000
--- a/addons/lunch/wizard/reset_box.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import ir
-import pooler
-
-set_to_zero_form = """
-"""
-
-
-
-confirm_setting_zero_fields = {}
-
-def _set_to_zero(self,cr,uid,data,context):
- pool= pooler.get_pool(cr.dbname)
- cashmove_ref = pool.get('lunch.cashmove')
- 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'])))
- res= cr.fetchall()
- cr.execute("update lunch_cashmove set active = 'f' where active= 't' and box in (%s)"%','.join(map(str,data['ids'])))
-## to_unactive= {}.fromkeys([r[0] for r in cr.fetchall]).keys()
-## print to_unactive
-## cashmove_ref.write(cr,uid,to_unactive,{'active':False})
-##
- for (user_id,box_id,amount) in res:
- cashmove_ref.create(cr,uid,{'name': 'Summary for user'+ str(user_id),
- 'amount': amount,
- 'user_cashmove': user_id,
- 'box': box_id,
- 'active': True,
- })
- return {}
-
-
-class cashbox_set_to_zero(wizard.interface):
-
- states = {
-
- 'init': {
- 'action':[],
- 'result':{'type' : 'form',
- 'arch' : set_to_zero_form,
- 'fields' : confirm_setting_zero_fields,
- 'state' : [('end', 'Cancel'),('zero', 'Set to Zero') ]},
-
- },
- 'zero' : {
- 'actions' : [_set_to_zero],
- 'result' : {'type' : 'state', 'state' : 'end'}
- },
- }
-
-cashbox_set_to_zero('lunch.cashbox.clean')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-