~grzegorz-og.pl/openobject-addons/extra-5.0_account_asset

« back to all changes in this revision

Viewing changes to c2c_analytic_wizard/wizard/indicator_account_detail.py

  • Committer: nicolas.bessi at camptocamp
  • Date: 2009-07-10 13:34:11 UTC
  • Revision ID: nicolas.bessi@camptocamp.com-20090710133411-mm1hd38lwe0wxcol
adding c2c_modules in stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
# Copyright (c) Camptocamp (http://www.camptocamp.com) All Rights Reserved.
 
5
#
 
6
# author: awu ported by nbessi
 
7
#
 
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
 
13
# Service Company
 
14
#
 
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.
 
19
#
 
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.
 
24
#
 
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.
 
28
#
 
29
##############################################################################
 
30
 
 
31
 
 
32
import wizard
 
33
import netsvc
 
34
import time
 
35
import pooler
 
36
from osv import osv
 
37
 
 
38
 
 
39
 
 
40
class wiz_account_detail(wizard.interface):
 
41
    """ a wizard that display a report that list projects and their invoices 
 
42
        this wizard is inspired (/copied) from 
 
43
        the class wiz_invoices_from_proj in 
 
44
        addons/specific_fct/wizard/open_specific_invoices.py
 
45
    """
 
46
 
 
47
 
 
48
    def _get_select_projects_ids(self, cr, uid, data, context):
 
49
        """ Return the list of projects selected before to call the wizard. """
 
50
        
 
51
        if not len(data['ids']):
 
52
            return {}
 
53
        pool = pooler.get_pool(cr.dbname)
 
54
        try :
 
55
            cr.execute(
 
56
                        "SELECT id from account_analytic_account \
 
57
                        where id in (%s)" , 
 
58
                        (",".join(map(str,data['ids'])),)
 
59
                        )
 
60
            projects_ids = cr.fetchall()
 
61
        except Exception, e:
 
62
            cr.rollback()
 
63
            raise wizard.except_wizard(
 
64
                                        'Error !', 
 
65
                                         str(e)
 
66
                                      )
 
67
        
 
68
        
 
69
        res = {'projects': [x[0] for x in projects_ids]}
 
70
        return res
 
71
            
 
72
        
 
73
    def _get_print_projects_ids(self, cr, uid, data, context):       
 
74
        """ return the list of projects selected in the wizard's 
 
75
            first form that match the criterias """
 
76
        
 
77
        #values from the form
 
78
        projects_ids = data['form']['projects'][0][2]
 
79
        open_only = data['form']['open_only']
 
80
        supplier_too = data['form']['supplier_too']
 
81
            
 
82
        values = {'ids': projects_ids, 
 
83
                  'open_only': open_only,
 
84
                  'supplier_too': supplier_too,
 
85
                 }
 
86
        return values
 
87
 
 
88
        
 
89
    _create_form = """<?xml version="1.0"?>
 
90
    <form string="Get projects details">
 
91
        <separator string="Filter By Project" colspan="4"/>
 
92
        <field name="projects" colspan="4" nolabel="1"/>
 
93
        <separator string="Filter Options" colspan="4"/>
 
94
        <field name="open_only"/>
 
95
        <field name="supplier_too"/>
 
96
    </form>"""
 
97
 
 
98
    _create_fields = {
 
99
        'projects': {
 
100
                        'string':'Projects', 
 
101
                        'type':'many2many', 
 
102
                        'required':'true', 
 
103
                        'relation':'account.analytic.account'
 
104
                    },
 
105
        'open_only': {
 
106
                        'string':'Open Invoices Only', 
 
107
                        'type':'boolean'
 
108
                    },
 
109
        'supplier_too': {
 
110
                            'string':'Display Suppliers Invoices', 
 
111
                            'type':'boolean'
 
112
                        },
 
113
    }
 
114
 
 
115
    states = {
 
116
        'init' : {
 
117
            'actions' : [_get_select_projects_ids], 
 
118
            'result' : {
 
119
                            'type':'form', 'arch':_create_form, 
 
120
                            'fields':_create_fields, 
 
121
                            'state': [
 
122
                                        ('end','Cancel'),
 
123
                                        ('print','Open Report')
 
124
                                    ]
 
125
                        },
 
126
        },
 
127
        'print' : {
 
128
            'actions': [_get_print_projects_ids],
 
129
            'result': {
 
130
                            'type':'print', 
 
131
                            'report':'indicator.account.detail', 
 
132
                            'get_id_from_action':True, 
 
133
                            'state':'end'
 
134
                        },            
 
135
            },
 
136
 
 
137
    }
 
138
wiz_account_detail('indicator.account.detail')
 
 
b'\\ No newline at end of file'