~alejandro-morera/siesa/siesa

« back to all changes in this revision

Viewing changes to account_financial_report/wizard/wizard_invoice_list_report.py

  • Committer: Alejando Morera
  • Date: 2014-12-22 22:01:31 UTC
  • Revision ID: alejandro.morera@siesacr.com-20141222220131-hy8actyew52x1qjd
[ADD] add files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
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>
 
8
#    $Id$
 
9
#
 
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.
 
14
#
 
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.
 
19
#
 
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/>.
 
22
#
 
23
##############################################################################
 
24
 
 
25
import wizard
 
26
import pooler
 
27
import time
 
28
from tools.translate import _
 
29
 
 
30
period_form = '''<?xml version="1.0"?>
 
31
<form string="Invoice List">
 
32
    <field name="company_id"/>
 
33
    <newline/>
 
34
    <group colspan="4">
 
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"/>
 
40
    </group>
 
41
    <group colspan="4">
 
42
        <separator string="Filter by state" colspan="4"/>
 
43
        <field name="draft"/>
 
44
        <field name="proforma"/>
 
45
        <field name="open"/>
 
46
        <field name="paid"/>
 
47
        <field name="cancel"/>
 
48
    </group>
 
49
    <group colspan="4">
 
50
        <separator string="Filter by date (default current year)" colspan="4"/>
 
51
        <field name="state" required="True"/>
 
52
        <newline/>
 
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"/>
 
58
            </group>
 
59
            <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
 
60
                <separator string="Filter on Periods" colspan="4"/>
 
61
                <field name="periods" colspan="4" nolabel="1"/>
 
62
            </group>
 
63
        </group>
 
64
    </group>
 
65
    <group colspan="4">
 
66
        <separator string="Options" colspan="4"/>
 
67
        <field name="detailed_taxes" required="False"/>
 
68
        <field name="order_by" required="True"/>
 
69
    </group>
 
70
</form>'''
 
71
 
 
72
period_fields = {
 
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',},
 
84
    'state':{
 
85
        'string':"Date/Period Filter",
 
86
        'type':'selection',
 
87
        'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],
 
88
        'default': lambda *a:'none'
 
89
    },
 
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'},
 
94
}
 
95
 
 
96
 
 
97
 
 
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)
 
101
        if user.company_id:
 
102
           company_id = user.company_id.id
 
103
        else:
 
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
 
107
        return data['form']
 
108
 
 
109
 
 
110
    states = {
 
111
        'init': {
 
112
            'actions': [_get_defaults],
 
113
            'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel','gtk-cancel'),('report','Print','gtk-print')]}
 
114
        },
 
115
        'report': {
 
116
            'actions': [],
 
117
            'result': {'type':'print', 'report':'account.invoice.list.report', 'state':'end'}
 
118
        }
 
119
    }
 
120
wizard_report('account.invoice.list.report')
 
121
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: