diff --git a/hotel_calendar_channel_connector/models/inherited_hotel_calendar_management.py b/hotel_calendar_channel_connector/models/inherited_hotel_calendar_management.py index b121372d3..28eeab040 100644 --- a/hotel_calendar_channel_connector/models/inherited_hotel_calendar_management.py +++ b/hotel_calendar_channel_connector/models/inherited_hotel_calendar_management.py @@ -11,9 +11,8 @@ class HotelCalendarManagement(models.TransientModel): vals = super(HotelCalendarManagement, self)._get_availability_values( avail, room_type) vals.update({ - 'wmax_avail': vals['avail'], - 'no_ota': vals['no_ota'], - 'booked': vals['booked'], + 'channel_max_avail': vals['avail'], + 'no_ota': avail['no_ota'], }) return vals diff --git a/hotel_calendar_channel_connector/models/inherited_hotel_reservation.py b/hotel_calendar_channel_connector/models/inherited_hotel_reservation.py index 32247a18d..fd7435e58 100644 --- a/hotel_calendar_channel_connector/models/inherited_hotel_reservation.py +++ b/hotel_calendar_channel_connector/models/inherited_hotel_reservation.py @@ -27,15 +27,17 @@ class HotelReservation(models.Model): room_name, partner_phone, state, fix_days) reserv = self.env['hotel.reservation'].browse(vals['reserv_id']) vals['reservation'].update({ - 'fix_days': (reserv.wrid and reserv.wrid != '') or fix_days, - 'wchannel': (reserv.wchannel_id and reserv.wchannel_id.name), + 'fix_days': (any(reserv.channel_bind_ids) and + reserv.channel_bind_ids[0].external_id) or fix_days, + 'ota_id': (any(reserv.channel_bind_ids) and + reserv.channel_bind_ids[0].ota_id and + reserv.channel_bind_ids[0].ota_id.name), }) return vals @api.multi def _hcalendar_reservation_data(self, reservations): - vals = super(HotelReservation, self)._hcalendar_reservation_data( - reservations) + vals = super(HotelReservation, self)._hcalendar_reservation_data(reservations) hotel_reservation_obj = self.env['hotel.reservation'] json_reservations = [] for v_rval in vals[0]: @@ -56,12 +58,16 @@ class HotelReservation(models.Model): # Read-Only False, # Fix Days - (reserv.wrid and reserv.wrid != '') or reserv.splitted, + (any(reserv.channel_bind_ids) and + reserv.channel_bind_ids[0].external_id) or reserv.splitted, # Fix Rooms False, reserv.overbooking)) # Update tooltips - vals[1][reserv.id].append(reserv.wchannel_id.name) + if any(reserv.channel_bind_ids): + vals[1][reserv.id].append(reserv.channel_bind_ids[0].ota_id.name) + else: + vals[1][reserv.id].append(False) return (json_reservations, vals[1]) @api.multi @@ -92,7 +98,8 @@ class HotelReservation(models.Model): 'fix_days': record.splitted or record.is_from_ota, 'overbooking': record.overbooking, 'price': record.folio_id.amount_total, - 'wrid': record.wrid, + 'external_id': (any(record.channel_bind_ids) and + record.channel_bind_ids[0].external_id), }) @api.multi diff --git a/hotel_channel_connector/models/hotel_reservation/common.py b/hotel_channel_connector/models/hotel_reservation/common.py index c0e059130..5475bb318 100644 --- a/hotel_channel_connector/models/hotel_reservation/common.py +++ b/hotel_channel_connector/models/hotel_reservation/common.py @@ -178,7 +178,8 @@ class HotelReservation(models.Model): def unlink(self): vals = [] for record in self: - if record.wrid and not record.parent_reservation: + if any(record.channel_bind_ids) and record.channel_bind_ids[0].external_id \ + and not record.parent_reservation: raise UserError(_("You can't delete OTA's reservations")) vals.append({ 'checkin': record.checkin,