From 6cb8124ee10e87edd3566e29a7e6c4cf3f49b328 Mon Sep 17 00:00:00 2001 From: "atp (Open ERP)" Date: Tue, 16 Mar 2010 11:05:49 +0530 Subject: [PATCH] [IMP]: lunch: Converted wizards to osv_memory wizards bzr revid: atp@tinyerp.co.in-20100316053549-vn01oispwwqc9xpg --- addons/lunch/__terp__.py | 6 +- addons/lunch/lunch_wizard.xml | 25 ------ addons/lunch/wizard/__init__.py | 7 +- addons/lunch/wizard/lunch_cashbox_clean.py | 54 +++++++++++++ .../lunch/wizard/lunch_cashbox_clean_view.xml | 38 ++++++++++ .../{cancel.py => lunch_order_cancel.py} | 47 +++++------- .../lunch/wizard/lunch_order_cancel_view.xml | 38 ++++++++++ .../{confirm.py => lunch_order_confirm.py} | 59 ++++++-------- .../lunch/wizard/lunch_order_confirm_view.xml | 40 ++++++++++ addons/lunch/wizard/reset_box.py | 76 ------------------- 10 files changed, 220 insertions(+), 170 deletions(-) delete mode 100644 addons/lunch/lunch_wizard.xml create mode 100644 addons/lunch/wizard/lunch_cashbox_clean.py create mode 100644 addons/lunch/wizard/lunch_cashbox_clean_view.xml rename addons/lunch/wizard/{cancel.py => lunch_order_cancel.py} (58%) create mode 100644 addons/lunch/wizard/lunch_order_cancel_view.xml rename addons/lunch/wizard/{confirm.py => lunch_order_confirm.py} (50%) create mode 100644 addons/lunch/wizard/lunch_order_confirm_view.xml delete mode 100644 addons/lunch/wizard/reset_box.py 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 + +
+ + + + +