~mga/openobject-addons/account_india

« back to all changes in this revision

Viewing changes to hotel_reservation/report/hotel_reservation_report.py

Add hotel's module

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import time
 
2
from report import report_sxw
 
3
import datetime
 
4
import pooler
 
5
class reservation_detail_report(report_sxw.rml_parse):
 
6
    def __init__(self, cr, uid, name, context):
 
7
        super(reservation_detail_report, self).__init__(cr, uid, name, context)
 
8
        print "dadasdasda"
 
9
        self.localcontext.update( {
 
10
            'time': time,
 
11
            'get_data': self.get_data,
 
12
            'get_checkin': self.get_checkin,
 
13
            'get_checkout': self.get_checkout,
 
14
            'get_room':self.get_room,
 
15
            
 
16
        })
 
17
        self.context=context
 
18
        
 
19
    def get_data(self,date_start,date_end):
 
20
        tids = self.pool.get('hotel.reservation').search(self.cr,self.uid,[('checkin', '>=', date_start),('checkout', '<=', date_end)])
 
21
        res = self.pool.get('hotel.reservation').browse(self.cr,self.uid,tids)
 
22
        print res
 
23
        return res
 
24
    
 
25
    def get_checkin(self,date_start,date_end):
 
26
        tids = self.pool.get('hotel.reservation').search(self.cr,self.uid,[('checkin', '>=', date_start),('checkin', '<=', date_end)])
 
27
        res = self.pool.get('hotel.reservation').browse(self.cr,self.uid,tids)
 
28
        print res
 
29
        return res
 
30
    
 
31
    def get_checkout(self,date_start,date_end):
 
32
        tids = self.pool.get('hotel.reservation').search(self.cr,self.uid,[('checkout', '>=', date_start),('checkout', '<=', date_end)])
 
33
        res = self.pool.get('hotel.reservation').browse(self.cr,self.uid,tids)
 
34
        print res
 
35
        return res
 
36
    
 
37
    def get_room(self,date_start,date_end):
 
38
        
 
39
        print "method--------"
 
40
        self.cr.execute("select pt.name,count(pt.name) as No_of_times from hotel_reservation as hr " \
 
41
                   "inner join hotel_reservation_line as hrl on hrl.line_id=hr.id " \
 
42
                   "inner join hotel_reservation_line_room_rel as hrlrr on hrlrr.room_id=hrl.id " \
 
43
                   "inner join product_product as pp on pp.product_tmpl_id=hrlrr.hotel_reservation_line_id " \
 
44
                   "inner join product_template as pt on pt.id=pp.product_tmpl_id " \
 
45
                   "where hr.state<>'draft' and hr.checkin >= %s and hr.checkout <= %s group by pt.name " \
 
46
                   ,(date_start,date_end)
 
47
                  
 
48
                   )
 
49
        res2=self.cr.dictfetchall()
 
50
        print res2
 
51
        return res2
 
52
    
 
53
        
 
54
 
 
55
report_sxw.report_sxw('report.reservation.detail', 'hotel.reservation', 'addons/hotel_reservation/report/room_res.rml',parser= reservation_detail_report)
 
56
report_sxw.report_sxw('report.checkin.detail', 'hotel.reservation', 'addons/hotel_reservation/report/checkinlist.rml',parser= reservation_detail_report)  
 
57
report_sxw.report_sxw('report.checkout.detail', 'hotel.reservation', 'addons/hotel_reservation/report/checkoutlist.rml',parser= reservation_detail_report)            
 
58
report_sxw.report_sxw('report.maxroom.detail', 'hotel.reservation', 'addons/hotel_reservation/report/maxroom.rml',parser= reservation_detail_report)
 
59
                  
 
 
b'\\ No newline at end of file'