[ADD] account_voucher: change accont_voucher_open wizard to osv_memory
bzr revid: psi@tinyerp.co.in-20100430090859-aurxcf7i2lmyfw3b
This commit is contained in:
parent
1be6c4da0c
commit
d2ebfdb884
|
@ -50,6 +50,7 @@
|
|||
"voucher_view.xml",
|
||||
"voucher_wizard.xml",
|
||||
"account_view.xml",
|
||||
"wizard/account_voucher_open_view.xml",
|
||||
],
|
||||
'certificate': '0037580727101',
|
||||
"active": False,
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<wizard
|
||||
id="wizard_account_voucher_open"
|
||||
model="account.voucher"
|
||||
name="account.voucher.open"
|
||||
menu="False"
|
||||
string="Open a Voucher Entry"/>
|
||||
<menuitem
|
||||
action="wizard_account_voucher_open"
|
||||
id="menu_wizard_account_voucher_open"
|
||||
|
||||
<!-- <wizard
|
||||
id="wizard_account_voucher_open"
|
||||
model="account.voucher"
|
||||
name="account.voucher.open"
|
||||
menu="False"
|
||||
string="Open a Voucher Entry"/>
|
||||
<menuitem
|
||||
action="wizard_account_voucher_open"
|
||||
id="menu_wizard_account_voucher_open"
|
||||
name="Open Vouchers"
|
||||
sequence="0"
|
||||
sequence="0"
|
||||
type="wizard"
|
||||
parent="menu_action_voucher_list"/>
|
||||
parent="menu_action_voucher_list"/> -->
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,8 +15,8 @@
|
|||
# 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 open_voucher
|
||||
import account_voucher_open
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 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 osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
_types = {
|
||||
'pay_voucher':'Cash Payment Voucher',
|
||||
'bank_pay_voucher':'Bank Payment Voucher',
|
||||
'rec_voucher':'Cash Receipt Voucher',
|
||||
'bank_rec_voucher':'Bank Receipt Voucher',
|
||||
'cont_voucher':'Contra Voucher',
|
||||
'journal_sale_vou':'Journal Sale Voucher',
|
||||
'journal_pur_voucher':'Journal Purchase Voucher'
|
||||
}
|
||||
_states = {
|
||||
'draft':'Draft',
|
||||
'proforma':'Pro-forma',
|
||||
'posted':'Posted',
|
||||
'cancel':'Cancel'
|
||||
}
|
||||
|
||||
class account_open_voucher(osv.osv_memory):
|
||||
_name = "account.open.voucher"
|
||||
_description = "Account Open Voucher"
|
||||
|
||||
_columns = {
|
||||
'type': fields.selection([('pay_voucher','Cash Payment Voucher'),
|
||||
('bank_pay_voucher','Bank Payment Voucher'),
|
||||
('rec_voucher','Cash Receipt Voucher'),
|
||||
('bank_rec_voucher','Bank Receipt Voucher'),
|
||||
('cont_voucher','Contra Voucher'),
|
||||
('journal_sale_vou','Journal Sale Voucher'),
|
||||
('journal_pur_voucher','Journal Purchase Voucher')],'Voucher Type', required=True),
|
||||
'state': fields.selection([('draft','Draft'),
|
||||
('proforma','Pro-forma'),
|
||||
('posted','Posted'),
|
||||
('cancel','Cancel')], 'State', required=True),
|
||||
'period_ids': fields.many2many('account.period', 'voucher_period_rel', 'voucher_id', 'period_id', 'Periods'),
|
||||
}
|
||||
|
||||
def action_open_window(self, cr, uid, ids, context=None):
|
||||
obj_period = self.pool.get('account.period')
|
||||
obj_fyear = self.pool.get('account.fiscalyear')
|
||||
periods = []
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
form = self.read(cr, uid, ids, [])[0]
|
||||
if not form['period_ids']:
|
||||
year = obj_fyear.find(cr, uid)
|
||||
periods = obj_period.search(cr, uid, [('fiscalyear_id','=',year)])
|
||||
else:
|
||||
periods = form['period_ids']
|
||||
return {
|
||||
'domain': "[('type','=','%s'), ('state','=','%s'), ('period_id','in',%s)]" % (form['type'], form['state'], periods),
|
||||
'name': "%s - %s" % (_types[form['type']], _states[form['state']]),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.voucher',
|
||||
'view_id': False,
|
||||
'context': "{'type':'%s', 'state':'%s', 'period_id':%s}" % (form['type'], form['state'], periods),
|
||||
'type': 'ir.actions.act_window',
|
||||
'nodestroy': True
|
||||
}
|
||||
|
||||
account_open_voucher()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="account_open_vouchers_view" model="ir.ui.view">
|
||||
<field name="name">Open Vouchers</field>
|
||||
<field name="model">account.open.voucher</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Open Vouchers">
|
||||
<field name="type"/>
|
||||
<field name="state"/>
|
||||
<field name="period_ids" colspan="4"/>
|
||||
<group colspan="4" col="6">
|
||||
<separator colspan="6"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="action_open_window" string="Open Voucher Entries" type="object" icon="gtk-ok"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_open_vouchers" model="ir.actions.act_window">
|
||||
<field name="name">Open Vouchers</field>
|
||||
<field name="res_model">account.open.voucher</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="account_open_vouchers_view"/>
|
||||
<field name="context">{'record_id':active_id}</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
icon="STOCK_EXECUTE"
|
||||
name="Open Vouchers"
|
||||
action="action_account_open_vouchers"
|
||||
id="menu_account_voucher_open"
|
||||
parent="menu_action_voucher_list"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,104 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 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
|
||||
from tools.translate import _
|
||||
import pooler
|
||||
|
||||
_voucher_form = '''<?xml version="1.0"?>
|
||||
<form string="Open Vouchers">
|
||||
<field name="type"/>
|
||||
<field name="state"/>
|
||||
<field name="period_ids" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
_types = {
|
||||
'pay_voucher':'Cash Payment Voucher',
|
||||
'bank_pay_voucher':'Bank Payment Voucher',
|
||||
'rec_voucher':'Cash Receipt Voucher',
|
||||
'bank_rec_voucher':'Bank Receipt Voucher',
|
||||
'cont_voucher':'Contra Voucher',
|
||||
'journal_sale_vou':'Journal Sale Voucher',
|
||||
'journal_pur_voucher':'Journal Purchase Voucher'
|
||||
}
|
||||
_states = {
|
||||
'draft':'Draft',
|
||||
'proforma':'Pro-forma',
|
||||
'posted':'Posted',
|
||||
'cancel':'Cancel'
|
||||
}
|
||||
|
||||
_voucher_fields = {
|
||||
'type': {'string':'Voucher Type', 'type':'selection', 'selection':[
|
||||
('pay_voucher','Cash Payment Voucher'),
|
||||
('bank_pay_voucher','Bank Payment Voucher'),
|
||||
('rec_voucher','Cash Receipt Voucher'),
|
||||
('bank_rec_voucher','Bank Receipt Voucher'),
|
||||
('cont_voucher','Contra Voucher'),
|
||||
('journal_sale_vou','Journal Sale Voucher'),
|
||||
('journal_pur_voucher','Journal Purchase Voucher')], 'required':True},
|
||||
'state': {'string':'State', 'type':'selection', 'selection':[
|
||||
('draft','Draft'),
|
||||
('proforma','Pro-forma'),
|
||||
('posted','Posted'),
|
||||
('cancel','Cancel')], 'required':True},
|
||||
'period_ids': {'string':'Periods', 'type':'many2many', 'relation':'account.period'},
|
||||
}
|
||||
|
||||
def _action_open_window(self, cr, uid, data, context):
|
||||
form = data['form']
|
||||
periods = []
|
||||
|
||||
if not form['period_ids'][0][2]:
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
period = pool.get('account.period')
|
||||
year = pool.get('account.fiscalyear')
|
||||
|
||||
year = year.find(cr, uid)
|
||||
periods = period.search(cr, uid, [('fiscalyear_id','=',year)])
|
||||
else:
|
||||
periods = form['period_ids'][0][2]
|
||||
|
||||
return {
|
||||
'domain': "[('type','=','%s'), ('state','=','%s'), ('period_id','in',%s)]" % (form['type'], form['state'], periods),
|
||||
'name': "%s - %s" % (_types[form['type']], _states[form['state']]),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.voucher',
|
||||
'view_id': False,
|
||||
'context': "{'type':'%s', 'state':'%s', 'period_id':%s}" % (form['type'], form['state'], periods),
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
|
||||
class OpenVoucherEntries(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type': 'form', 'arch':_voucher_form, 'fields':_voucher_fields, 'state':[('end','Cancel'),('open','Open Voucher Entries')]}
|
||||
},
|
||||
'open': {
|
||||
'actions': [],
|
||||
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
|
||||
}
|
||||
}
|
||||
OpenVoucherEntries('account.voucher.open')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
Loading…
Reference in New Issue