mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Use Hotel Node Helper for Wizard Node Reservation
This commit is contained in:
@@ -64,25 +64,12 @@ class HotelNodeReservationWizard(models.TransientModel):
|
|||||||
if checkin >= checkout:
|
if checkin >= checkout:
|
||||||
checkout = checkin + timedelta(days=1)
|
checkout = checkin + timedelta(days=1)
|
||||||
|
|
||||||
# rooms_availability = noderpc.env['hotel.room.type'].check_availability_room(checkin, checkout) # return str
|
free_room_ids = noderpc.env['hotel.room.type'].check_availability_room_ids(checkin, checkout)
|
||||||
# TODO add check_availability_room in a hotel slave node module
|
|
||||||
|
|
||||||
reservation_ids = noderpc.env['hotel.reservation'].search([
|
|
||||||
('reservation_line_ids.date', '>=', checkin),
|
|
||||||
('reservation_line_ids.date', '<', checkout),
|
|
||||||
('state', '!=', 'cancelled'),
|
|
||||||
('overbooking', '=', False)
|
|
||||||
])
|
|
||||||
|
|
||||||
reservation_room_ids = []
|
|
||||||
# do not trust even your father
|
|
||||||
if reservation_ids:
|
|
||||||
reservation_room_ids = noderpc.env['hotel.reservation'].browse(reservation_ids).mapped('room_id.id')
|
|
||||||
|
|
||||||
room_type_availability = {}
|
room_type_availability = {}
|
||||||
for room_type in self.node_id.room_type_ids:
|
for room_type in self.node_id.room_type_ids:
|
||||||
room_type_availability[room_type.id] = noderpc.env['hotel.room'].search_count([
|
room_type_availability[room_type.id] = noderpc.env['hotel.room'].search_count([
|
||||||
('id', 'not in', reservation_room_ids),
|
('id', 'in', free_room_ids),
|
||||||
('room_type_id', '=', room_type.remote_room_type_id)
|
('room_type_id', '=', room_type.remote_room_type_id)
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -137,6 +124,8 @@ class HotelNodeReservationWizard(models.TransientModel):
|
|||||||
}))
|
}))
|
||||||
vals.update({'room_lines': room_lines})
|
vals.update({'room_lines': room_lines})
|
||||||
|
|
||||||
|
wdb.set_trace()
|
||||||
|
|
||||||
x = noderpc.env['hotel.reservation'].create(vals)
|
x = noderpc.env['hotel.reservation'].create(vals)
|
||||||
|
|
||||||
noderpc.logout()
|
noderpc.logout()
|
||||||
|
|||||||
Reference in New Issue
Block a user