1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6
# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
7
# Jordi Esteve <jesteve@zikzakmedia.com>
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation, either version 3 of the License, or
13
# (at your option) any later version.
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU General Public License for more details.
20
# You should have received a copy of the GNU General Public License
21
# along with this program. If not, see <http://www.gnu.org/licenses/>.
23
##############################################################################
28
from tools.translate import _
30
period_form = '''<?xml version="1.0"?>
31
<form string="Select period">
32
<field name="company_id"/>
34
<separator string="Filter by type" colspan="4"/>
35
<field name="out_invoice"/>
36
<field name="out_refund"/>
37
<field name="in_invoice"/>
38
<field name="in_refund"/>
39
<separator string="Filter by state" colspan="4"/>
41
<field name="proforma"/>
44
<field name="cancel"/>
45
<separator string="Filter by date" colspan="4"/>
46
<field name="state" required="True"/>
48
<group attrs="{'invisible':[('state','=','none')]}" colspan="4">
49
<group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">
50
<separator string="Date Filter" colspan="4"/>
51
<field name="date_from"/>
52
<field name="date_to"/>
54
<group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
55
<separator string="Filter on Periods" colspan="4"/>
56
<field name="periods" colspan="4" nolabel="1"/>
59
<separator string="Options" colspan="4"/>
60
<field name="detailed_taxes" required="False"/>
64
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
65
'out_invoice': {'string':'Customer invoices', 'type':'boolean', 'default': lambda *a: True},
66
'out_refund': {'string':'Customer refunds', 'type':'boolean', 'default': lambda *a: True},
67
'in_invoice': {'string':'Supplier invoices', 'type':'boolean', 'default': lambda *a: True},
68
'in_refund': {'string':'Supplier refunds', 'type':'boolean', 'default': lambda *a: True},
69
'draft': {'string':'Draft', 'type':'boolean',},
70
'proforma': {'string':'Pro-forma', 'type':'boolean',},
71
'open': {'string':'Open', 'type':'boolean', 'default': lambda *a: True},
72
'paid': {'string':'Done', 'type':'boolean', 'default': lambda *a: True},
73
'cancel': {'string':'Cancelled', 'type':'boolean',},
74
'detailed_taxes': {'string':'Detailed taxes', 'type':'boolean',},
76
'string':"Date/Period Filter",
78
'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],
79
'default': lambda *a:'none'
81
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
82
'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
83
'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
88
class wizard_report(wizard.interface):
89
def _get_defaults(self, cr, uid, data, context={}):
90
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
92
company_id = user.company_id.id
94
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
95
data['form']['company_id'] = company_id
96
data['form']['context'] = context
102
'actions': [_get_defaults],
103
'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel','gtk-cancel'),('report','Print','gtk-print')]}
107
'result': {'type':'print', 'report':'account.invoice.list.report', 'state':'end'}
110
wizard_report('account.invoice.list.report')
111
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: