diff --git a/hotel_channel_connector/models/channel_backend/common.py b/hotel_channel_connector/models/channel_backend/common.py index 4797d3c4d..6440c087c 100644 --- a/hotel_channel_connector/models/channel_backend/common.py +++ b/hotel_channel_connector/models/channel_backend/common.py @@ -267,11 +267,11 @@ class ChannelBackend(models.Model): _logger.warning(msg) email_values.update({'body_html': email_values['body_html'] + msg + '
'}) - if len(email_values['body_html']) > 0: - template = self.env.ref('hotel_channel_connector.mail_template_hotel_availability_watchdog') - email_values.update({'email_to': self._context['email_to']}) - template.send_mail(self.id, email_values=email_values) + if 'email_to' in self._context: + template = self.env.ref('hotel_channel_connector.mail_template_hotel_availability_watchdog') + email_values.update({'email_to': self._context['email_to']}) + template.send_mail(self.id, email_values=email_values) # push availability on demand self.with_context({'show_notify': False}).push_availability() diff --git a/hotel_channel_connector/models/inherited_hotel_room.py b/hotel_channel_connector/models/inherited_hotel_room.py index bf411908f..b297cba99 100644 --- a/hotel_channel_connector/models/inherited_hotel_room.py +++ b/hotel_channel_connector/models/inherited_hotel_room.py @@ -61,7 +61,7 @@ class HotelRoom(models.Model): channel_availability = self.env['channel.hotel.room.type.availability'].search([ ('room_type_id', '=', item['old_room_type_id']), - ('channel_avail', '>=', old_room_type_total_rooms_count), + ('channel_avail', '>', old_room_type_total_rooms_count), ('date', '>=', _today) ], order='date asc') or False if channel_availability: @@ -119,6 +119,11 @@ class HotelRoom(models.Model): checkout=dto, backend_id=new_channel_room_type.backend_id.id, room_type_id=item['new_room_type_id'], ) + # TODO: channel_backend MUST be the same for both room types + channel_backend = self.env['channel.hotel.room.type'].search([ + ('odoo_id', '=', vals.get('room_type_id')) + ]).backend_id + channel_backend.channel_availability_watchdog() else: res = super().write(vals) return res