[ADD,MOD] account_payment : wizard_pay converted to osv memory wizard

bzr revid: vir@tinyerp.com-20100430115154-wbvl3a6pqzw0nc00
This commit is contained in:
Vir (Open ERP) 2010-04-30 17:21:54 +05:30
parent 7162874a62
commit 2d412ce412
5 changed files with 73 additions and 46 deletions

View File

@ -38,6 +38,7 @@
'update_xml': [
'security/account_payment_security.xml',
'security/ir.model.access.csv',
'wizard/wizard_pay_view.xml',
'payment_wizard.xml',
'wizard/account_payment_create_order_view.xml',
'payment_view.xml',
@ -45,6 +46,7 @@
'payment_sequence.xml',
'account_invoice_view.xml',
'payment_report.xml',
],
'demo_xml': [],
'installable': True,

View File

@ -162,7 +162,7 @@
<group col="4" colspan="2">
<button name="cancel" states="draft,open" string="Cancel" icon="gtk-cancel"/>
<button name="open" states="draft" string="Confirm Payments" icon="gtk-apply"/>
<button name="%(wizard_pay_payment)d" states="open" string="Make Payments" type="action" icon="gtk-execute"/>
<button name="%(action_account_payment_make_payment)d" states="open" string="Make Payments" type="action" icon="gtk-execute"/>
<button name="set_to_draft" states="cancel" string="Set to draft" type="object" icon="gtk-convert"/>
</group>
</form>

View File

@ -3,7 +3,7 @@
<data>
<!--<wizard id="wizard_populate_payment" menu="False" model="payment.order" name="populate_payment" string="Populate payment"/>-->
<wizard id="wizard_pay_payment" menu="False" model="payment.order" name="pay_payment" string="Pay"/>
<!-- <wizard id="wizard_pay_payment" menu="False" model="payment.order" name="pay_payment" string="Pay"/>-->
<wizard id="wizard_populate_statement" menu="False" model="account.bank.statement" name="populate_statement" string="Populate Statement with Payment lines"/>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,54 +15,46 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
from osv import osv
import pooler
from osv import fields
import time
from osv import fields, osv
class account_payment_make_payment(osv.osv_memory):
_name = 'account.payment.make.payment'
_description = 'Account make payment'
_columns = {
}
def launch_wizard(self, cr, uid, ids, context):
"""
Search for a wizard to launch according to the type.
If type is manual. just confirm the order.
"""
obj_payment_order = self.pool.get('payment.order')
obj_model = self.pool.get('ir.model.data')
obj_act = self.pool.get('ir.actions.act_window')
order= obj_payment_order.browse(cr,uid,context['active_id'],context)
t= order.mode and order.mode.type.code or 'manual'
if t == 'manual' :
obj_payment_order.set_done(cr,uid,context['active_id'],context)
return {}
gw= obj_payment_order.get_wizard(t)
if not gw:
obj_payment_order.set_done(cr,uid,context['active_id'],context)
return {}
module, wizard= gw
result = mod_obj._get_id(cr, uid, module, wizard)
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
#result['context'] = str({'fiscalyear': data['form']['fiscalyear']})
return result
def _launch_wizard(self, cr, uid, data, context):
"""
Search for a wizard to launch according to the type.
If type is manual. just confirm the order.
"""
order_ref= pooler.get_pool(cr.dbname).get('payment.order')
order= order_ref.browse(cr,uid,data['id'],context)
t= order.mode and order.mode.type.code or 'manual'
if t == 'manual' :
order_ref.set_done(cr,uid,data['id'],context)
return {}
gw= order_ref.get_wizard(t)
if not gw:
order_ref.set_done(cr,uid,data['id'],context)
return {}
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.wizard')
module, wizard= gw
result = mod_obj._get_id(cr, uid, module, wizard)
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
#result['context'] = str({'fiscalyear': data['form']['fiscalyear']})
return result
class wizard_pay(wizard.interface):
states= {'init' : {'actions': [],
'result':{'type':'action',
'action':_launch_wizard,
'state':'end'}
}
}
wizard_pay('pay_payment')
account_payment_make_payment()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="account_payment_make_payment_view" model="ir.ui.view">
<field name="name">account.payment.make.payment.form</field>
<field name="model">account.payment.make.payment</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Make Payment">
<label string ="Are you sure you want to make payment?" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="launch_wizard" string="Print" type="object" icon="gtk-print" default_focus="1"/>
</group>
</form>
</field>
</record>
<record id="action_account_payment_make_payment" model="ir.actions.act_window">
<field name="name">Make Payment</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.payment.make.payment</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="account_payment_make_payment_view"/>
<field name="target">new</field>
</record>
</data>
</openerp>