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 Affero 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 Affero General Public License for more details.
20
# You should have received a copy of the GNU Affero 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="Invoice List">
32
<field name="company_id"/>
35
<separator string="Filter by type" colspan="4"/>
36
<field name="out_invoice"/>
37
<field name="out_refund"/>
38
<field name="in_invoice"/>
39
<field name="in_refund"/>
42
<separator string="Filter by state" colspan="4"/>
44
<field name="proforma"/>
47
<field name="cancel"/>
50
<separator string="Filter by date (default current year)" colspan="4"/>
51
<field name="state" required="True"/>
53
<group attrs="{'invisible':[('state','=','none')]}" colspan="4">
54
<group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">
55
<separator string="Date Filter" colspan="4"/>
56
<field name="date_from"/>
57
<field name="date_to"/>
59
<group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
60
<separator string="Filter on Periods" colspan="4"/>
61
<field name="periods" colspan="4" nolabel="1"/>
66
<separator string="Options" colspan="4"/>
67
<field name="detailed_taxes" required="False"/>
68
<field name="order_by" required="True"/>
73
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
74
'out_invoice': {'string':'Customer invoices', 'type':'boolean', 'default': lambda *a: True},
75
'out_refund': {'string':'Customer refunds', 'type':'boolean', 'default': lambda *a: True},
76
'in_invoice': {'string':'Supplier invoices', 'type':'boolean', 'default': lambda *a: True},
77
'in_refund': {'string':'Supplier refunds', 'type':'boolean', 'default': lambda *a: True},
78
'draft': {'string':'Draft', 'type':'boolean',},
79
'proforma': {'string':'Pro-forma', 'type':'boolean',},
80
'open': {'string':'Open', 'type':'boolean', 'default': lambda *a: True},
81
'paid': {'string':'Done', 'type':'boolean', 'default': lambda *a: True},
82
'cancel': {'string':'Cancelled', 'type':'boolean',},
83
'detailed_taxes': {'string':'Detailed taxes', 'type':'boolean',},
85
'string':"Date/Period Filter",
87
'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],
88
'default': lambda *a:'none'
90
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
91
'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
92
'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
93
'order_by': {'string': 'Order by', 'type': 'selection', 'selection': [('number','Number'),('date','Date'),('partner','Partner')], 'default': lambda *a: 'number'},
98
class wizard_report(wizard.interface):
99
def _get_defaults(self, cr, uid, data, context={}):
100
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
102
company_id = user.company_id.id
104
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
105
data['form']['company_id'] = company_id
106
data['form']['context'] = context
112
'actions': [_get_defaults],
113
'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel','gtk-cancel'),('report','Print','gtk-print')]}
117
'result': {'type':'print', 'report':'account.invoice.list.report', 'state':'end'}
120
wizard_report('account.invoice.list.report')
121
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: