1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
8
# WARNING: This program as such is intended to be used by professional
9
# programmers who take the whole responsability of assessing all potential
10
# consequences resulting from its eventual inadequacies and bugs
11
# End users who are looking for a ready-to-use solution with commercial
12
# garantees and support are strongly adviced to contract a Free Software
15
# This program is Free Software; you can redistribute it and/or
16
# modify it under the terms of the GNU General Public License
17
# as published by the Free Software Foundation; either version 2
18
# of the License, or (at your option) any later version.
20
# This program is distributed in the hope that it will be useful,
21
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
# GNU General Public License for more details.
25
# You should have received a copy of the GNU General Public License
26
# along with this program; if not, write to the Free Software
27
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29
##############################################################################
32
from tools.translate import _
35
_voucher_form = '''<?xml version="1.0"?>
36
<form string="Open Vouchers">
39
<field name="period_ids" colspan="4"/>
43
'pay_voucher':'Cash Payment Voucher',
44
'bank_pay_voucher':'Bank Payment Voucher',
45
'rec_voucher':'Cash Receipt Voucher',
46
'bank_rec_voucher':'Bank Receipt Voucher',
47
'cont_voucher':'Contra Voucher',
48
'journal_sale_voucher':'Journal Sale Voucher',
49
'journal_pur_voucher':'Journal Purchase Voucher'
53
'proforma':'Pro-forma',
59
'type': {'string':'Voucher Type', 'type':'selection', 'selection':[
60
('pay_voucher','Cash Payment Voucher'),
61
('bank_pay_voucher','Bank Payment Voucher'),
62
('rec_voucher','Cash Receipt Voucher'),
63
('bank_rec_voucher','Bank Receipt Voucher'),
64
('cont_voucher','Contra Voucher'),
65
('journal_sale_voucher','Journal Sale Voucher'),
66
('journal_pur_voucher','Journal Purchase Voucher')], 'required':True},
67
'state': {'string':'State', 'type':'selection', 'selection':[
69
('proforma','Pro-forma'),
71
('cancel','Cancel')], 'required':True},
72
'period_ids': {'string':'Periods', 'type':'many2many', 'relation':'account.period'},
75
def _action_open_window(self, cr, uid, data, context):
79
if not form['period_ids'][0][2]:
80
pool = pooler.get_pool(cr.dbname)
81
period = pool.get('account.period')
82
year = pool.get('account.fiscalyear')
84
year = year.find(cr, uid)
85
periods = period.search(cr, uid, [('fiscalyear_id','=',year)])
87
periods = form['period_ids'][0][2]
90
'domain': "[('type','=','%s'), ('state','=','%s'), ('period_id','in',%s)]" % (form['type'], form['state'], periods),
91
'name': "%s - %s" % (_types[form['type']], _states[form['state']]),
93
'view_mode': 'tree,form',
94
'res_model': 'account.voucher',
96
'context': "{'type':'%s', 'state':'%s', 'period_id':%s}" % (form['type'], form['state'], periods),
97
'type': 'ir.actions.act_window'
100
class OpenVoucherEntries(wizard.interface):
104
'result': {'type': 'form', 'arch':_voucher_form, 'fields':_voucher_fields, 'state':[('end','Cancel'),('open','Open Voucher Entries')]}
108
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
111
OpenVoucherEntries('account.voucher.open')
113
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: