~anna-g/micronaet/anna

« back to all changes in this revision

Viewing changes to hr_auto/report/res_car_document_expiry_report.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
 
# -*- encoding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
# Copyright (c) 2009 Dhaval Patel (dhpatel82 at gmail.com)
5
 
#                          All Rights Reserved.
6
 
#
7
 
# WARNING: This program as such is intended to be used by professional
8
 
# programmers who take the whole responsability of assessing all potential
9
 
# consequences resulting from its eventual inadequacies and bugs
10
 
# End users who are looking for a ready-to-use solution with commercial
11
 
# garantees and support are strongly adviced to contract a Free Software
12
 
# Service Company
13
 
#
14
 
# This program is Free Software; you can redistribute it and/or
15
 
# modify it under the terms of the GNU General Public License
16
 
# as published by the Free Software Foundation; either version 2
17
 
# of the License, or (at your option) any later version.
18
 
#
19
 
# This program is distributed in the hope that it will be useful,
20
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 
# GNU General Public License for more details.
23
 
#
24
 
# You should have received a copy of the GNU General Public License
25
 
# along with this program; if not, write to the Free Software
26
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27
 
#
28
 
##############################################################################
29
 
import time
30
 
from report import report_sxw
31
 
import pooler
32
 
import datetime
33
 
 
34
 
class res_car_document_expiry_report(report_sxw.rml_parse):
35
 
 
36
 
    def __init__(self, cr, uid, name, context):
37
 
        super(res_car_document_expiry_report, self).__init__(cr, uid, name, context=context)
38
 
        self.month = False
39
 
        self.year = False
40
 
        self.localcontext.update({
41
 
            'time': time,
42
 
            'get_car': self.get_car,
43
 
            'get_car_documents': self.get_car_documents,
44
 
        })
45
 
    def get_car(self, form):
46
 
        result = []
47
 
        periods = []
48
 
        car = pooler.get_pool(self.cr.dbname).get('res.car')
49
 
        car_ids = form['ids']
50
 
        result = car.browse(self.cr,self.uid, car_ids)
51
 
        self.date_from = form['date_from']
52
 
        self.date_to = form['date_to']
53
 
        return result
54
 
    def get_car_documents(self, obj):
55
 
        result = []
56
 
        periods = []
57
 
        doc = pooler.get_pool(self.cr.dbname).get('res.car.document')
58
 
        doc_ids = doc.search(self.cr, self.uid, [('car_id','=',obj.id), ('valid_end_date', '>=', self.date_from), ('valid_end_date', '<=', self.date_to)])
59
 
        result = doc.browse(self.cr, self.uid, doc_ids)
60
 
        return result
61
 
 
62
 
report_sxw.report_sxw('report.res.car.document.expiry', 'res.car', 'addons/hr_auto/report/res_car_document_expiry_report.rml', parser=res_car_document_expiry_report, header='internal')
63
 
 
64
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
65