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

« back to all changes in this revision

Viewing changes to hotel/hotel.py

  • Committer: nel
  • Date: 2008-06-30 10:08:55 UTC
  • Revision ID: nel-1b5e620223399a90d1ec6b552c6a45f2e4a10d3c
added the module for hotel booking

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##############################################################################
 
2
#
 
3
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
 
4
#                    Fabien Pinckaers <fp@tiny.Be>
 
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
from osv import fields
 
29
from osv import osv
 
30
import time
 
31
import netsvc
 
32
import ir
 
33
from mx import DateTime
 
34
import datetime
 
35
import pooler
 
36
from tools import config
 
37
 
 
38
class hotel_floor(osv.osv):
 
39
    _name = "hotel.floor"
 
40
    _description = "Floor"
 
41
    _columns = { 
 
42
        'name': fields.char('Floor Name', size=64, required=True,select=True),
 
43
        'sequence' : fields.integer('Sequence', size=64),
 
44
        }    
 
45
hotel_floor()
 
46
 
 
47
class product_category(osv.osv):
 
48
    _inherit="product.category"
 
49
    _columns = {
 
50
        'isroomtype':fields.boolean('Is Room Type'),
 
51
        'isamenitype':fields.boolean('Is amenities Type'),
 
52
        'isservicetype':fields.boolean('Is Service Type'),
 
53
    }
 
54
product_category()
 
55
 
 
56
class hotel_room_type(osv.osv):
 
57
    _name = "hotel.room_type"
 
58
    _inherits = {'product.category':'cat_id'}
 
59
    _description = "Room Type"
 
60
    _columns = { 
 
61
        'cat_id':fields.many2one('product.category','category',required=True,select=True),
 
62
   
 
63
    }
 
64
    _defaults = {
 
65
        'isroomtype': lambda *a: 1,
 
66
    }    
 
67
hotel_room_type()
 
68
 
 
69
 
 
70
class product_product(osv.osv):
 
71
    _inherit="product.product"
 
72
    _columns = {
 
73
        'isroom':fields.boolean('Is Room'),
 
74
        'iscategid':fields.boolean('Is categ id'),
 
75
        'isservice':fields.boolean('Is Service id'),
 
76
                
 
77
    }
 
78
product_product()
 
79
 
 
80
class hotel_room_amenities_type(osv.osv):
 
81
    _name='hotel.room_amenities_type'
 
82
    _description='amenities Type'
 
83
    _inherits = {'product.category':'cat_id'}
 
84
    _columns = {
 
85
        'cat_id':fields.many2one('product.category','category',required=True),
 
86
       }
 
87
    _defaults = {
 
88
        'isamenitype': lambda *a: 1,
 
89
        
 
90
    }
 
91
 
 
92
hotel_room_amenities_type()
 
93
 
 
94
class hotel_room_amenities(osv.osv):
 
95
    _name='hotel.room_amenities'
 
96
    _description='Room amenities'
 
97
    _inherits={'product.product':'room_categ_id'}
 
98
    _columns = {
 
99
               
 
100
         'room_categ_id':fields.many2one('product.product','Product Category',required=True),
 
101
         'rcateg_id':fields.many2one('hotel.room_amenities_type','Amenity Catagory'),   
 
102
         'amenity_rate':fields.integer('Amenity Rate'),
 
103
 
 
104
 
 
105
        }
 
106
    _defaults = {
 
107
        'iscategid': lambda *a: 1,
 
108
        }
 
109
        
 
110
#end class
 
111
hotel_room_amenities()
 
112
 
 
113
 
 
114
class hotel_room(osv.osv):
 
115
  
 
116
    _name='hotel.room'
 
117
    _inherits={'product.product':'product_id'}
 
118
    _description='Hotel Room'
 
119
    _columns = {
 
120
 
 
121
        'product_id': fields.many2one('product.product','Product_id'),
 
122
        'floor_id':fields.many2one('hotel.floor','Floor No'),
 
123
        'maxAdult':fields.integer('Max Adult'),
 
124
        'maxChild':fields.integer('Max Child'),
 
125
        'avail_status':fields.selection([('assigned','Assigned'),(' unassigned','Unassigned')],'Room Status'),
 
126
        'room_amenities':fields.many2many('hotel.room_amenities','temp_tab','room_amenities','rcateg_id','Room Amenities'),
 
127
        }
 
128
    _defaults = {
 
129
        'isroom': lambda *a: 1,
 
130
        'rental': lambda *a: 1,
 
131
        }
 
132
 
 
133
hotel_room()
 
134
 
 
135
 
 
136
class hotel_folio(osv.osv):
 
137
    
 
138
    def _incoterm_get(self, cr, uid, context={}):
 
139
        return  self.pool.get('sale.order')._incoterm_get(cr, uid, context={})
 
140
    def copy(self, cr, uid, id, default=None,context={}):
 
141
        return  self.pool.get('sale.order').copy(cr, uid, id, default=None,context={})
 
142
    def _invoiced(self, cursor, user, ids, name, arg, context=None):
 
143
        return  self.pool.get('sale.order')._invoiced(cursor, user, ids, name, arg, context=None)
 
144
    def _invoiced_search(self, cursor, user, obj, name, args):
 
145
        return  self.pool.get('sale.order')._invoiced_search(cursor, user, obj, name, args)
 
146
    def _amount_untaxed(self, cr, uid, ids, field_name, arg, context):
 
147
        return self.pool.get('sale.order')._amount_untaxed(cr, uid, ids, field_name, arg, context)
 
148
    def _amount_tax(self, cr, uid, ids, field_name, arg, context):
 
149
        return self.pool.get('sale.order')._amount_tax(cr, uid, ids, field_name, arg, context)
 
150
    def _amount_total(self, cr, uid, ids, field_name, arg, context):
 
151
        return self.pool.get('sale.order')._amount_total(cr, uid, ids, field_name, arg, context)
 
152
        
 
153
    _name='hotel.folio'
 
154
    _description='hotel folio new'
 
155
    _inherits={'sale.order':'order_id'}
 
156
    _columns={
 
157
          'order_id':fields.many2one('sale.order','order_id',required=True,ondelete='cascade'),
 
158
          'checkin_date': fields.datetime('Check In',required=True,readonly=True, states={'draft':[('readonly',False)]}),
 
159
          'checkout_date': fields.datetime('Check Out',required=True,readonly=True, states={'draft':[('readonly',False)]}),
 
160
          'room_lines': fields.one2many('hotel_folio.line','folio_id'),
 
161
          'service_lines': fields.one2many('hotel_service.line','folio_id'),
 
162
    }
 
163
    
 
164
    def create(self, cr, uid, vals, context=None, check=True):
 
165
        tmp_room_lines = vals['room_lines']
 
166
        tmp_service_lines = vals['service_lines']
 
167
        if not vals.has_key("folio_id"):
 
168
            vals.update({'room_lines':[],'service_lines':[]})
 
169
            folio_id = super(hotel_folio, self).create(cr, uid, vals, context)
 
170
            for line in tmp_room_lines:
 
171
                line[2].update({'folio_id':folio_id})
 
172
            for line in tmp_service_lines:
 
173
                line[2].update({'folio_id':folio_id})
 
174
            vals.update({'room_lines':tmp_room_lines,'service_lines':tmp_service_lines})
 
175
            super(hotel_folio, self).write(cr, uid,[folio_id], vals, context)
 
176
        else:
 
177
            folio_id = super(hotel_folio, self).create(cr, uid, vals, context)
 
178
        return folio_id
 
179
    
 
180
   
 
181
    def onchange_shop_id(self, cr, uid, ids, shop_id):
 
182
        return  self.pool.get('sale.order').onchange_shop_id(cr, uid, ids, shop_id)
 
183
    def onchange_partner_id(self, cr, uid, ids, part):
 
184
        return  self.pool.get('sale.order').onchange_partner_id(cr, uid, ids, part)
 
185
    def button_dummy(self, cr, uid, ids, context={}):
 
186
        return  self.pool.get('sale.order').button_dummy(cr, uid, ids, context={})
 
187
    
 
188
    def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed','done']):
 
189
        i = self.pool.get('sale.order').action_invoice_create(cr, uid, ids, grouped=False, states=['confirmed','done'])
 
190
        for line in self.browse(cr, uid, ids, context={}):
 
191
            self.write(cr, uid, [line.id], {'invoiced':True})
 
192
            if grouped:
 
193
               self.write(cr, uid, [line.id], {'state' : 'progress'})
 
194
            else:
 
195
               self.write(cr, uid, [line.id], {'state' : 'progress'})
 
196
        return i 
 
197
 
 
198
   
 
199
    def action_invoice_cancel(self, cr, uid, ids, context={}):
 
200
        res = self.pool.get('sale.order').action_invoice_cancel(cr, uid, ids, context={})
 
201
        for sale in self.browse(cr, uid, ids):
 
202
            for line in sale.order_line:
 
203
                self.pool.get('sale.order.line').write(cr, uid, [line.id], {'invoiced': invoiced})
 
204
        self.write(cr, uid, ids, {'state':'invoice_except', 'invoice_id':False})
 
205
        return res  
 
206
    def action_cancel(self, cr, uid, ids, context={}):
 
207
        c = self.pool.get('sale.order').action_cancel(cr, uid, ids, context={})
 
208
        ok = True
 
209
        for sale in self.browse(cr, uid, ids):
 
210
            for r in self.read(cr,uid,ids,['picking_ids']):
 
211
                for pick in r['picking_ids']:
 
212
                    wf_service = netsvc.LocalService("workflow")
 
213
                    wf_service.trg_validate(uid, 'stock.picking', pick, 'button_cancel', cr)
 
214
            for r in self.read(cr,uid,ids,['invoice_ids']):
 
215
                for inv in r['invoice_ids']:
 
216
                    wf_service = netsvc.LocalService("workflow")
 
217
                    wf_service.trg_validate(uid, 'account.invoice', inv, 'invoice_cancel', cr)
 
218
            
 
219
        self.write(cr,uid,ids,{'state':'cancel'})
 
220
        return c
 
221
    
 
222
    def action_wait(self, cr, uid, ids, *args):
 
223
        res = self.pool.get('sale.order').action_wait(cr, uid, ids, *args)
 
224
        for o in self.browse(cr, uid, ids):
 
225
            if (o.order_policy == 'manual') and (not o.invoice_ids):
 
226
                self.write(cr, uid, [o.id], {'state': 'manual'})
 
227
            else:
 
228
                self.write(cr, uid, [o.id], {'state': 'progress'})
 
229
        return res
 
230
    def test_state(self, cr, uid, ids, mode, *args):
 
231
        write_done_ids = []
 
232
        write_cancel_ids = []
 
233
        res = self.pool.get('sale.order').test_state(cr, uid, ids, mode, *args)
 
234
        if write_done_ids:
 
235
            self.pool.get('sale.order.line').write(cr, uid, write_done_ids, {'state': 'done'})
 
236
        if write_cancel_ids:
 
237
            self.pool.get('sale.order.line').write(cr, uid, write_cancel_ids, {'state': 'cancel'})
 
238
        return res 
 
239
    def procurement_lines_get(self, cr, uid, ids, *args):
 
240
        res = self.pool.get('sale.order').procurement_lines_get(cr, uid, ids, *args)
 
241
        return  res
 
242
    def action_ship_create(self, cr, uid, ids, *args):
 
243
        res =  self.pool.get('sale.order').action_ship_create(cr, uid, ids, *args)
 
244
        picking_id=False
 
245
        for order in self.browse(cr, uid, ids, context={}):
 
246
            for line in order.order_line:
 
247
                proc_id=False
 
248
                if line.state == 'done':
 
249
                    continue
 
250
                    wf_service = netsvc.LocalService("workflow")
 
251
                    wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
 
252
                    self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
 
253
                else:
 
254
                    wf_service = netsvc.LocalService("workflow")
 
255
                    wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
 
256
                    self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
 
257
 
 
258
            val = {}
 
259
            if picking_id:
 
260
                wf_service = netsvc.LocalService("workflow")
 
261
                wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
 
262
                #val = {'picking_ids':[(6,0,[picking_id])]}
 
263
 
 
264
            if order.state=='shipping_except':
 
265
                val['state'] = 'progress'
 
266
                if (order.order_policy == 'manual') and order.invoice_ids:
 
267
                    val['state'] = 'manual'
 
268
            self.write(cr, uid, [order.id], val)
 
269
        return res
 
270
    def action_ship_end(self, cr, uid, ids, context={}):
 
271
        res = self.pool.get('sale.order').action_ship_end(cr, uid, ids, context={})
 
272
        for order in self.browse(cr, uid, ids):
 
273
            val = {'shipped':True}
 
274
            self.write(cr, uid, [order.id], val)
 
275
        return res 
 
276
    def _log_event(self, cr, uid, ids, factor=0.7, name='Open Order'):
 
277
        return  self.pool.get('sale.order')._log_event(cr, uid, ids, factor=0.7, name='Open Order')
 
278
    def has_stockable_products(self,cr, uid, ids, *args):
 
279
        return  self.pool.get('sale.order').has_stockable_products(cr, uid, ids, *args)
 
280
    def action_cancel_draft(self, cr, uid, ids, *args):
 
281
        d = self.pool.get('sale.order').action_cancel_draft(cr, uid, ids, *args)
 
282
        self.write(cr, uid, ids, {'state':'draft', 'invoice_ids':[], 'shipped':0})
 
283
        self.pool.get('sale.order.line').write(cr, uid, line_ids, {'invoiced':False, 'state':'draft', 'invoice_lines':[(6,0,[])]})
 
284
        return d
 
285
  
 
286
hotel_folio()
 
287
 
 
288
class hotel_folio_line(osv.osv):
 
289
    
 
290
    def copy(self, cr, uid, id, default=None, context={}):
 
291
        return  self.pool.get('sale.order.line').copy(cr, uid, id, default=None, context={})
 
292
    def _amount_line_net(self, cr, uid, ids, field_name, arg, context):
 
293
        return  self.pool.get('sale.order.line')._amount_line_net(cr, uid, ids, field_name, arg, context)
 
294
    def _amount_line(self, cr, uid, ids, field_name, arg, context):
 
295
        return  self.pool.get('sale.order.line')._amount_line(cr, uid, ids, field_name, arg, context)
 
296
    def _number_packages(self, cr, uid, ids, field_name, arg, context):
 
297
        return  self.pool.get('sale.order.line')._number_packages(cr, uid, ids, field_name, arg, context)
 
298
    def _get_1st_packaging(self, cr, uid, context={}):
 
299
        return  self.pool.get('sale.order.line')._get_1st_packaging(cr, uid, context={})
 
300
    def _get_checkin_date(self,cr, uid, context={}):
 
301
        if 'checkin_date' in context:
 
302
            return context['checkin_date']
 
303
        return time.strftime('%Y-%m-%d %H:%M:%S')
 
304
    def _get_checkout_date(self,cr, uid, context={}):
 
305
        if 'checkin_date' in context:
 
306
            return context['checkout_date']
 
307
        return time.strftime('%Y-%m-%d %H:%M:%S')
 
308
 
 
309
    _name='hotel_folio.line'
 
310
    _description='hotel folio1 room line'
 
311
    _inherits={'sale.order.line':'order_line_id'}
 
312
    _columns={
 
313
          'order_line_id':fields.many2one('sale.order.line','order_line_id',required=True,ondelete='cascade'),
 
314
          'folio_id':fields.many2one('hotel.folio','folio_id',ondelete='cascade'),
 
315
          'checkin_date': fields.datetime('Check In',required=True),
 
316
          'checkout_date': fields.datetime('Check Out',required=True),
 
317
    }
 
318
    _defaults={
 
319
       'checkin_date':_get_checkin_date,
 
320
       'checkout_date':_get_checkout_date,
 
321
       
 
322
    }
 
323
 
 
324
    def create(self, cr, uid, vals, context=None, check=True):
 
325
        if not context:
 
326
            context={}
 
327
        if vals.has_key("folio_id"):
 
328
            folio = self.pool.get("hotel.folio").browse(cr,uid,[vals['folio_id']])[0]
 
329
            vals.update({'order_id':folio.order_id.id})
 
330
        roomline = super(osv.osv, self).create(cr, uid, vals, context)
 
331
        return roomline
 
332
    def uos_change(self, cr, uid, ids, product_uos, product_uos_qty=0, product_id=None):
 
333
        return  self.pool.get('sale.order.line').uos_change(cr, uid, ids, product_uos, product_uos_qty=0, product_id=None)
 
334
    def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
 
335
            uom=False, qty_uos=0, uos=False, name='', partner_id=False,
 
336
            lang=False, update_tax=True, date_order=False):
 
337
        return  self.pool.get('sale.order.line').product_id_change(cr, uid, ids, pricelist, product, qty=0,
 
338
            uom=False, qty_uos=0, uos=False, name='', partner_id=False,
 
339
            lang=False, update_tax=True, date_order=False)
 
340
    def product_uom_change(self, cursor, user, ids, pricelist, product, qty=0,
 
341
            uom=False, qty_uos=0, uos=False, name='', partner_id=False,
 
342
            lang=False, update_tax=True, date_order=False):
 
343
        return  self.pool.get('sale.order.line').product_uom_change(cursor, user, ids, pricelist, product, qty=0,
 
344
            uom=False, qty_uos=0, uos=False, name='', partner_id=False,
 
345
            lang=False, update_tax=True, date_order=False)
 
346
    def on_change_checkout(self,cr, uid, ids, checkin_date=time.strftime('%Y-%m-%d %H:%M:%S'),checkout_date=time.strftime('%Y-%m-%d %H:%M:%S'),context=None):
 
347
        qty = 1
 
348
        print checkin_date
 
349
        print checkout_date
 
350
        if checkout_date < checkin_date:
 
351
            raise osv.except_osv ('Error !','Checkout must be greater or equal checkin date')
 
352
        if checkin_date:
 
353
            diffDate = datetime.datetime(*time.strptime(checkout_date,'%Y-%m-%d %H:%M:%S')[:5]) - datetime.datetime(*time.strptime(checkin_date,'%Y-%m-%d %H:%M:%S')[:5])
 
354
            qty = diffDate.days
 
355
        return {'value':{'product_uom_qty':qty}}
 
356
    
 
357
    def button_confirm(self, cr, uid, ids, context={}):
 
358
       
 
359
        return  self.pool.get('sale.order.line').button_confirm(cr, uid, ids, context={})
 
360
    def button_done(self, cr, uid, ids, context={}):
 
361
        res = self.pool.get('sale.order.line').button_done(cr, uid, ids, context={})
 
362
        wf_service = netsvc.LocalService("workflow")
 
363
        res = self.write(cr, uid, ids, {'state':'done'})
 
364
        for line in self.browse(cr,uid,ids,context):
 
365
            wf_service.trg_write(uid, 'sale.order', line.order_id.id, cr)
 
366
        return res
 
367
 
 
368
        
 
369
    def uos_change(self, cr, uid, ids, product_uos, product_uos_qty=0, product_id=None):
 
370
        return  self.pool.get('sale.order.line').uos_change(cr, uid, ids, product_uos, product_uos_qty=0, product_id=None)
 
371
    def copy(self, cr, uid, id, default=None,context={}):
 
372
        return  self.pool.get('sale.order.line').copy(cr, uid, id, default=None,context={})
 
373
    
 
374
        
 
375
 
 
376
hotel_folio_line()
 
377
 
 
378
class hotel_service_line(osv.osv):
 
379
    
 
380
    def copy(self, cr, uid, id, default=None, context={}):
 
381
        return  self.pool.get('sale.order.line').copy(cr, uid, id, default=None, context={})
 
382
    def _amount_line_net(self, cr, uid, ids, field_name, arg, context):
 
383
        return  self.pool.get('sale.order.line')._amount_line_net(cr, uid, ids, field_name, arg, context)
 
384
    def _amount_line(self, cr, uid, ids, field_name, arg, context):
 
385
        return  self.pool.get('sale.order.line')._amount_line(cr, uid, ids, field_name, arg, context)
 
386
    def _number_packages(self, cr, uid, ids, field_name, arg, context):
 
387
        return  self.pool.get('sale.order.line')._number_packages(cr, uid, ids, field_name, arg, context)
 
388
    def _get_1st_packaging(self, cr, uid, context={}):
 
389
        return  self.pool.get('sale.order.line')._get_1st_packaging(cr, uid, context={})
 
390
   
 
391
 
 
392
    _name='hotel_service.line'
 
393
    _description='hotel Service line'
 
394
    _inherits={'sale.order.line':'service_line_id'}
 
395
    _columns={
 
396
          'service_line_id':fields.many2one('sale.order.line','service_line_id',required=True,ondelete='cascade'),
 
397
          'folio_id':fields.many2one('hotel.folio','folio_id',ondelete='cascade'),
 
398
         
 
399
    }
 
400
 
 
401
    def create(self, cr, uid, vals, context=None, check=True):
 
402
        if not context:
 
403
            context={}
 
404
        if vals.has_key("folio_id"):
 
405
            folio = self.pool.get("hotel.folio").browse(cr,uid,[vals['folio_id']])[0]
 
406
            vals.update({'order_id':folio.order_id.id})
 
407
        roomline = super(osv.osv, self).create(cr, uid, vals, context)
 
408
        return roomline
 
409
    def uos_change(self, cr, uid, ids, product_uos, product_uos_qty=0, product_id=None):
 
410
        return  self.pool.get('sale.order.line').uos_change(cr, uid, ids, product_uos, product_uos_qty=0, product_id=None)
 
411
    def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
 
412
            uom=False, qty_uos=0, uos=False, name='', partner_id=False,
 
413
            lang=False, update_tax=True, date_order=False):
 
414
        return  self.pool.get('sale.order.line').product_id_change(cr, uid, ids, pricelist, product, qty=0,
 
415
            uom=False, qty_uos=0, uos=False, name='', partner_id=False,
 
416
            lang=False, update_tax=True, date_order=False)
 
417
    def product_uom_change(self, cursor, user, ids, pricelist, product, qty=0,
 
418
            uom=False, qty_uos=0, uos=False, name='', partner_id=False,
 
419
            lang=False, update_tax=True, date_order=False):
 
420
        return  self.pool.get('sale.order.line').product_uom_change(cursor, user, ids, pricelist, product, qty=0,
 
421
            uom=False, qty_uos=0, uos=False, name='', partner_id=False,
 
422
            lang=False, update_tax=True, date_order=False)
 
423
    def on_change_checkout(self,cr, uid, ids, checkin_date=time.strftime('%Y-%m-%d %H:%M:%S'),checkout_date=time.strftime('%Y-%m-%d %H:%M:%S'),context=None):
 
424
        qty = 1
 
425
        print checkin_date
 
426
        print checkout_date
 
427
        if checkout_date < checkin_date:
 
428
            raise osv.except_osv ('Error !','Checkout must be greater or equal checkin date')
 
429
        if checkin_date:
 
430
            diffDate = datetime.datetime(*time.strptime(checkout_date,'%Y-%m-%d %H:%M:%S')[:5]) - datetime.datetime(*time.strptime(checkin_date,'%Y-%m-%d %H:%M:%S')[:5])
 
431
            qty = diffDate.days
 
432
        return {'value':{'product_uom_qty':qty}}
 
433
    
 
434
    def button_confirm(self, cr, uid, ids, context={}):
 
435
       
 
436
        return  self.pool.get('sale.order.line').button_confirm(cr, uid, ids, context={})
 
437
    def button_done(self, cr, uid, ids, context={}):
 
438
        return  self.pool.get('sale.order.line').button_done(cr, uid, ids, context={})
 
439
    def uos_change(self, cr, uid, ids, product_uos, product_uos_qty=0, product_id=None):
 
440
        return  self.pool.get('sale.order.line').uos_change(cr, uid, ids, product_uos, product_uos_qty=0, product_id=None)
 
441
    def copy(self, cr, uid, id, default=None,context={}):
 
442
        return  self.pool.get('sale.order.line').copy(cr, uid, id, default=None,context={})
 
443
    
 
444
        
 
445
 
 
446
hotel_service_line()
 
447
 
 
448
class hotel_service_type(osv.osv):
 
449
    _name = "hotel.service_type"
 
450
    _inherits = {'product.category':'ser_id'}
 
451
    _description = "Service Type"
 
452
    _columns = { 
 
453
        'ser_id':fields.many2one('product.category','category',required=True,select=True),
 
454
        
 
455
    }
 
456
    _defaults = {
 
457
        'isservicetype': lambda *a: 1,
 
458
    }    
 
459
#end class    
 
460
hotel_service_type()
 
461
 
 
462
class hotel_services(osv.osv):
 
463
    
 
464
    _name = 'hotel.services'
 
465
    _description = 'Hotel Services and its charges'
 
466
    _inherits={'product.product':'service_id'}
 
467
    _columns = {
 
468
        'service_id': fields.many2one('product.product','Service_id'),        
 
469
       
 
470
        }
 
471
    _defaults = {
 
472
        'isservice': lambda *a: 1,
 
473
        }
 
474
#end class
 
475
hotel_services()
 
476
    
 
477
    
 
478
 
 
479
 
 
480