[REF]: account_voucher: Converted all simple wizards to osv_memory wizards in account_voucher
bzr revid: rpa@openerp.co.in-20100302103913-686vj1p49yzlayrm
This commit is contained in:
committed by
rpa (Open ERP)
parent
f10a3d12f2
commit
a76ba1ceff
@@ -42,7 +42,8 @@
|
||||
"voucher_sequence.xml",
|
||||
"account_report.xml",
|
||||
"voucher_view.xml",
|
||||
"voucher_wizard.xml",
|
||||
"wizard/account_voucher_open_view.xml",
|
||||
#"voucher_wizard.xml",
|
||||
"account_view.xml",
|
||||
],
|
||||
'certificate': '0037580727101',
|
||||
|
||||
@@ -19,4 +19,5 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import open_voucher
|
||||
|
||||
import account_voucher_open
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
# -*- 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 time
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
import ir
|
||||
import pooler
|
||||
import mx.DateTime
|
||||
from mx.DateTime import RelativeDateTime
|
||||
from tools import config
|
||||
|
||||
class account_voucher_open(osv.osv_memory):
|
||||
"""
|
||||
Open Account Voucher
|
||||
"""
|
||||
_name ="account.voucher.open"
|
||||
_description ="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', 'account_period_rel', 'voucher_id', 'period_id', 'Periods')
|
||||
}
|
||||
def _action_open_window(self, cr, uid, ids, context):
|
||||
"""
|
||||
Open account voucher form.
|
||||
@param cr: the current row, from the database cursor.
|
||||
@param uid: the current user’s ID for security checks.
|
||||
@param id: account voucher open’s ID or list of IDs if we want more than one.
|
||||
@param return:dictionary of account voucher on given state ,type and account period id.
|
||||
"""
|
||||
|
||||
for form in self.read(cr, uid, ids):
|
||||
periods = []
|
||||
if not form['period_ids']:
|
||||
period = self.pool.get('account.period')
|
||||
year = self.pool.get('account.fiscalyear')
|
||||
year = year.find(cr, uid)
|
||||
periods = 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" % (form['type'],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'
|
||||
}
|
||||
account_voucher_open()
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_account_voucher_open_form" model="ir.ui.view">
|
||||
<field name="name">account.voucher.open.form</field>
|
||||
<field name="model">account.voucher.open</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Open Vouchers">
|
||||
<group colspan="4" >
|
||||
<field name="type"/>
|
||||
<field name="state"/>
|
||||
<field name="period_ids" colspan="4"/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<group colspan="4" col="6">
|
||||
<label string ="" colspan="2"/>
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button string="Open Voucher Entries" name="_action_open_window" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_account_voucher_open" model="ir.actions.act_window">
|
||||
<field name="name">Open a Voucher Entry</field>
|
||||
<field name="res_model">account.voucher.open</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_account_voucher_open_form"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
<menuitem
|
||||
action="action_account_voucher_open"
|
||||
id="menu_wizard_account_voucher_open"
|
||||
name="Open Vouchers"
|
||||
sequence="0"
|
||||
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:
|
||||
Reference in New Issue
Block a user