From a76ba1ceff9d033930e3321e973b6d670b60b3f8 Mon Sep 17 00:00:00 2001 From: "ATP (OpenERP)" <> Date: Tue, 2 Mar 2010 16:09:13 +0530 Subject: [PATCH] [REF]: account_voucher: Converted all simple wizards to osv_memory wizards in account_voucher bzr revid: rpa@openerp.co.in-20100302103913-686vj1p49yzlayrm --- addons/account_voucher/__terp__.py | 3 +- addons/account_voucher/wizard/__init__.py | 3 +- .../wizard/account_voucher_open.py | 76 +++++++++++++ .../wizard/account_voucher_open_view.xml | 39 +++++++ addons/account_voucher/wizard/open_voucher.py | 104 ------------------ 5 files changed, 119 insertions(+), 106 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/__terp__.py b/addons/account_voucher/__terp__.py index 242cc5fb391..cb2033abe06 100755 --- a/addons/account_voucher/__terp__.py +++ b/addons/account_voucher/__terp__.py @@ -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', diff --git a/addons/account_voucher/wizard/__init__.py b/addons/account_voucher/wizard/__init__.py index 136fd1d8ee9..237055f710d 100644 --- a/addons/account_voucher/wizard/__init__.py +++ b/addons/account_voucher/wizard/__init__.py @@ -19,4 +19,5 @@ # ############################################################################## -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..5c3448eb57f --- /dev/null +++ b/addons/account_voucher/wizard/account_voucher_open.py @@ -0,0 +1,76 @@ +# -*- 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 . +# +############################################################################## + +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() + + 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..c3ef1acf94e --- /dev/null +++ b/addons/account_voucher/wizard/account_voucher_open_view.xml @@ -0,0 +1,39 @@ + + + + + account.voucher.open.form + account.voucher.open + form + +
+ + + + + + + +