[IMP]: lunch: Converted wizards to osv_memory wizards
bzr revid: atp@tinyerp.co.in-20100316053549-vn01oispwwqc9xpg
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
<openerp>
|
||||
<data>
|
||||
<wizard
|
||||
string="Confirm Order"
|
||||
model="lunch.order"
|
||||
name="lunch.order.confirm"
|
||||
keyword="client_action_multi"
|
||||
id="lunch_order_confirm"/>
|
||||
|
||||
<wizard
|
||||
string="Cancel Order"
|
||||
model="lunch.order"
|
||||
name="lunch.order.cancel"
|
||||
keyword="client_action_multi"
|
||||
id="wizard_id_cancel"/>
|
||||
|
||||
<wizard
|
||||
string="Set CashBox to Zero"
|
||||
model="lunch.cashbox"
|
||||
name="lunch.cashbox.clean"
|
||||
keyword="client_action_multi"
|
||||
id="wizard_clean_cashbox"/>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -18,9 +18,8 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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:
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
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:
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_lunch_cashbox_clean" model="ir.ui.view">
|
||||
<field name="name">lunch.cashbox.clean.form</field>
|
||||
<field name="model">lunch.cashbox.clean</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Reset cashbox">
|
||||
<group colspan="4" >
|
||||
<label string="Are you sure you want to reset this cashbox ?"/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="No"/>
|
||||
<button icon="gtk-ok" name="set_to_zero" string="Set to Zero" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_lunch_cashbox_clean" model="ir.actions.act_window">
|
||||
<field name="name">Set CashBox to Zero</field>
|
||||
<field name="res_model">lunch.cashbox.clean</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_lunch_cashbox_clean"/>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'record_id':active_id}</field>
|
||||
</record>
|
||||
|
||||
<act_window id="action_lunch_cashbox_clean_values"
|
||||
key2="client_action_multi" name="Set CashBox to Zero"
|
||||
res_model="lunch.cashbox.clean" src_model="lunch.cashbox"
|
||||
view_mode="form" target="new" view_type="form" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -18,36 +18,25 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from osv import fields, osv
|
||||
|
||||
import wizard
|
||||
import netsvc
|
||||
import ir
|
||||
import pooler
|
||||
|
||||
cancel_form = """<?xml version="1.0"?>
|
||||
<form string="Cancel Order">
|
||||
<label string="Are you sure you want to cancel this order ?"/>
|
||||
</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:
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_lunch_order_cancel" model="ir.ui.view">
|
||||
<field name="name">lunch.order.cancel.form</field>
|
||||
<field name="model">lunch.order.cancel</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Cancel Order">
|
||||
<group colspan="4" >
|
||||
<label string="Are you sure you want to cancel this order ?"/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="No"/>
|
||||
<button icon="gtk-ok" name="cancel" string="Yes" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_lunch_order_cancel" model="ir.actions.act_window">
|
||||
<field name="name">Cancel Order</field>
|
||||
<field name="res_model">lunch.order.cancel</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_lunch_order_cancel"/>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'record_id':active_id}</field>
|
||||
</record>
|
||||
|
||||
<act_window id="action_lunch_order_cancel_values"
|
||||
key2="client_action_multi" name="Cancel Order"
|
||||
res_model="lunch.order.cancel" src_model="lunch.order"
|
||||
view_mode="form" target="new" view_type="form" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -19,42 +19,33 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import netsvc
|
||||
import ir
|
||||
import pooler
|
||||
from osv import fields, osv
|
||||
|
||||
confirm_order_form = """<?xml version="1.0"?>
|
||||
<form title="Confirm">
|
||||
<separator string="Orders Confirmation" colspan="4"/>
|
||||
<field name="confirm_cashbox"/>
|
||||
<newline/>
|
||||
</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:
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_lunch_order_confirm" model="ir.ui.view">
|
||||
<field name="name">lunch.order.confirm.form</field>
|
||||
<field name="model">lunch.order.confirm</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Confirm">
|
||||
<group colspan="4" >
|
||||
<separator string="Orders Confirmation" colspan="4"/>
|
||||
<field name="confirm_cashbox"/>
|
||||
<newline/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-ok" name="confirm" string="Confirm Order" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_lunch_order_confirm" model="ir.actions.act_window">
|
||||
<field name="name">Confirm Order</field>
|
||||
<field name="res_model">lunch.order.confirm</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_lunch_order_confirm"/>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'record_id':active_id}</field>
|
||||
</record>
|
||||
|
||||
<act_window id="action_lunch_order_confirm_values"
|
||||
key2="client_action_multi" name="Confirm Order"
|
||||
res_model="lunch.order.confirm" src_model="lunch.order"
|
||||
view_mode="form" target="new" view_type="form" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,76 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import netsvc
|
||||
import ir
|
||||
import pooler
|
||||
|
||||
set_to_zero_form = """<?xml version="1.0"?>
|
||||
<form string="Reset cashbox">
|
||||
<label string="Are you sure you want to reset this cashbox ?"/>
|
||||
</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:
|
||||
|
||||
Reference in New Issue
Block a user