~anna-g/micronaet/anna

« back to all changes in this revision

Viewing changes to contract_manage_report/report/contract_list.py

  • Committer: Anna Micronaet
  • Date: 2013-07-18 09:08:36 UTC
  • Revision ID: anna@micronaet.it-20130718090836-ssmst48rrnvcd69w
Tolti tutti i moduli

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
##############################################################################
2
 
#
3
 
# Copyright (c) 2008-2010 SIA "KN dati". (http://kndati.lv) All Rights Reserved.
4
 
#                    General contacts <info@kndati.lv>
5
 
#
6
 
# WARNING: This program as such is intended to be used by professional
7
 
# programmers who take the whole responsability of assessing all potential
8
 
# consequences resulting from its eventual inadequacies and bugs
9
 
# End users who are looking for a ready-to-use solution with commercial
10
 
# garantees and support are strongly adviced to contract a Free Software
11
 
# Service Company
12
 
#
13
 
# This program is Free Software; you can redistribute it and/or
14
 
# modify it under the terms of the GNU General Public License
15
 
# as published by the Free Software Foundation; either version 2
16
 
# of the License, or (at your option) any later version.
17
 
#
18
 
# This program is distributed in the hope that it will be useful,
19
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 
# GNU General Public License for more details.
22
 
#
23
 
# You should have received a copy of the GNU General Public License
24
 
# along with this program; if not, write to the Free Software
25
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
26
 
#
27
 
##############################################################################
28
 
 
29
 
from report import report_sxw
30
 
from report.report_sxw import rml_parse
31
 
 
32
 
class Parser(report_sxw.rml_parse):
33
 
    def __init__(self, cr, uid, name, context):
34
 
        super(Parser, self).__init__(cr, uid, name, context)
35
 
        self.localcontext.update({
36
 
            'get_contract': self.get_contract,
37
 
            'get_department': self.get_department,
38
 
        })
39
 
 
40
 
    def get_department(self, data=None):
41
 
        ''' Get department list with wizard parameter
42
 
        '''    
43
 
        # TODO interface with wizard (for department Id or all)
44
 
        if data is None: 
45
 
            data={}
46
 
        filter_dept=[]
47
 
        if data:
48
 
            
49
 
            dept=data.get('department_id', False)
50
 
            if dept:
51
 
                filter_dept=[('id','=',dept)]
52
 
 
53
 
        dept_pool = self.pool.get('hr.department')
54
 
        dept_ids = dept_pool.search(self.cr, self.uid, filter_dept, order='name')
55
 
        return dept_pool.browse(self.cr, self.uid, dept_ids)
56
 
        
57
 
    def get_contract(self, department_id, data=None):
58
 
        ''' Get list of contract with passed department
59
 
        '''    
60
 
 
61
 
        if data is None: 
62
 
            data={}
63
 
 
64
 
        domain=[('department_id','=',department_id)]
65
 
        contract_id = data.get('contract_id', False)
66
 
        if contract_id:
67
 
           domain.append(('id','=',contract_id))
68
 
        
69
 
        contract_pool = self.pool.get('account.analytic.account')
70
 
        contract_ids = contract_pool.search(self.cr, self.uid, domain, order='code,name')
71
 
        return contract_pool.browse(self.cr, self.uid, contract_ids)
72