From d2ebfdb884dd960f1f7a8e334d10bdd8042e123f Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Fri, 30 Apr 2010 14:38:59 +0530 Subject: [PATCH] [ADD] account_voucher: change accont_voucher_open wizard to osv_memory bzr revid: psi@tinyerp.co.in-20100430090859-aurxcf7i2lmyfw3b --- addons/account_voucher/__openerp__.py | 1 + addons/account_voucher/voucher_wizard.xml | 24 ++-- addons/account_voucher/wizard/__init__.py | 6 +- .../wizard/account_voucher_open.py | 86 +++++++++++++++ .../wizard/account_voucher_open_view.xml | 42 +++++++ addons/account_voucher/wizard/open_voucher.py | 104 ------------------ 6 files changed, 144 insertions(+), 119 deletions(-) create mode 100644 addons/account_voucher/wizard/account_voucher_open.py create mode 100644 addons/account_voucher/wizard/account_voucher_open_view.xml delete mode 100644 addons/account_voucher/wizard/open_voucher.py diff --git a/addons/account_voucher/__openerp__.py b/addons/account_voucher/__openerp__.py index a006cb10bab..a3813f47fee 100644 --- a/addons/account_voucher/__openerp__.py +++ b/addons/account_voucher/__openerp__.py @@ -50,6 +50,7 @@ "voucher_view.xml", "voucher_wizard.xml", "account_view.xml", + "wizard/account_voucher_open_view.xml", ], 'certificate': '0037580727101', "active": False, diff --git a/addons/account_voucher/voucher_wizard.xml b/addons/account_voucher/voucher_wizard.xml index 5e8a3f6ce5d..661acdd4241 100644 --- a/addons/account_voucher/voucher_wizard.xml +++ b/addons/account_voucher/voucher_wizard.xml @@ -1,20 +1,20 @@ - - - + + parent="menu_action_voucher_list"/> --> diff --git a/addons/account_voucher/wizard/__init__.py b/addons/account_voucher/wizard/__init__.py index 136fd1d8ee9..bd436ecd135 100644 --- a/addons/account_voucher/wizard/__init__.py +++ b/addons/account_voucher/wizard/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -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 . +# along with this program. If not, see . # ############################################################################## -import open_voucher +import account_voucher_open diff --git a/addons/account_voucher/wizard/account_voucher_open.py b/addons/account_voucher/wizard/account_voucher_open.py new file mode 100644 index 00000000000..b286217e106 --- /dev/null +++ b/addons/account_voucher/wizard/account_voucher_open.py @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 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 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: \ No newline at end of file diff --git a/addons/account_voucher/wizard/account_voucher_open_view.xml b/addons/account_voucher/wizard/account_voucher_open_view.xml new file mode 100644 index 00000000000..0d67c455c3f --- /dev/null +++ b/addons/account_voucher/wizard/account_voucher_open_view.xml @@ -0,0 +1,42 @@ + + + + + + Open Vouchers + account.open.voucher + form + +
+ + + + + +