~openerp-commiter/openobject-addons/extra-6.0

« back to all changes in this revision

Viewing changes to account_financial_report/wizard/wizard_invoice_list_report.py

  • Committer: Borja L.S.
  • Date: 2010-04-07 17:17:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4498.
  • Revision ID: borjals@pexego.es-20100407171706-bdyhd0essc5237g2
[ADD] account_financial_report: Added the module from the 5.0 extra-addons.

  This module from the 5.0 extra-addons was missing on the 
  trunk extra-addons branch.
 
  We have just tested that it works with the 5.2 version.

  The module adds some extra financial/accounting reports:
  * Account chart list
  * Invoice list
  * Account move (journal ledger)
  * Account move line
  * Account balance compared period-fiscal year
  * Cumulative general ledger

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 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 General Public License for more details.
 
19
#
 
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/>.
 
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="Select period">
 
32
    <field name="company_id"/>
 
33
    <newline/>
 
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"/>
 
40
    <field name="draft"/>
 
41
    <field name="proforma"/>
 
42
    <field name="open"/>
 
43
    <field name="paid"/>
 
44
    <field name="cancel"/>
 
45
    <separator string="Filter by date" colspan="4"/>
 
46
    <field name="state" required="True"/>
 
47
    <newline/>
 
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"/>
 
53
        </group>
 
54
        <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
 
55
            <separator string="Filter on Periods" colspan="4"/>
 
56
            <field name="periods" colspan="4" nolabel="1"/>
 
57
        </group>
 
58
    </group>
 
59
    <separator string="Options" colspan="4"/>
 
60
    <field name="detailed_taxes" required="False"/>
 
61
</form>'''
 
62
 
 
63
period_fields = {
 
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',},
 
75
    'state':{
 
76
        'string':"Date/Period Filter",
 
77
        'type':'selection',
 
78
        'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],
 
79
        'default': lambda *a:'none'
 
80
    },
 
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')},
 
84
}
 
85
 
 
86
 
 
87
 
 
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)
 
91
        if user.company_id:
 
92
           company_id = user.company_id.id
 
93
        else:
 
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
 
97
        return data['form']
 
98
 
 
99
 
 
100
    states = {
 
101
        'init': {
 
102
            'actions': [_get_defaults],
 
103
            'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel','gtk-cancel'),('report','Print','gtk-print')]}
 
104
        },
 
105
        'report': {
 
106
            'actions': [],
 
107
            'result': {'type':'print', 'report':'account.invoice.list.report', 'state':'end'}
 
108
        }
 
109
    }
 
110
wizard_report('account.invoice.list.report')
 
111
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: