diff --git a/hotel_channel_connector/models/hotel_room_type_restriction/common.py b/hotel_channel_connector/models/hotel_room_type_restriction/common.py index 4cd669c67..c8d902198 100644 --- a/hotel_channel_connector/models/hotel_room_type_restriction/common.py +++ b/hotel_channel_connector/models/hotel_room_type_restriction/common.py @@ -53,6 +53,7 @@ class ChannelHotelRoomTypeRestriction(models.Model): importer = work.component(usage='hotel.room.type.restriction.importer') return importer.import_restriction_plans() + class HotelRoomTypeRestriction(models.Model): _inherit = 'hotel.room.type.restriction' @@ -99,10 +100,15 @@ class HotelRoomTypeRestriction(models.Model): @api.multi def disconnect_channel_bind_ids(self): - channel_bind_ids = self.mapped('channel_bind_ids') - msg = _("This function is not yet implemented.") - msg += _(" The restriction plan [%s] should be delete from the channel manager.") % channel_bind_ids.get_external_id - raise UserError(msg) + # TODO: multichannel rooms is not implemented + self.channel_bind_ids.with_context({'connector_no_export': True}).unlink() + + @api.multi + def write(self, vals): + if 'active' in vals and vals.get('active') is False: + self.channel_bind_ids.unlink() + return super().write(vals) + class BindingHotelRoomTypeListener(Component): _name = 'binding.hotel.room.type.restriction.listener' @@ -115,6 +121,7 @@ class BindingHotelRoomTypeListener(Component): for binding in record.channel_bind_ids: binding.update_plan_name() + class ChannelBindingHotelRoomTypeRestrictionListener(Component): _name = 'channel.binding.hotel.room.type.restriction.listener' _inherit = 'base.connector.listener' diff --git a/hotel_channel_connector/views/inherited_hotel_room_type_restriction_views.xml b/hotel_channel_connector/views/inherited_hotel_room_type_restriction_views.xml index 9cb595e56..e822a7328 100644 --- a/hotel_channel_connector/views/inherited_hotel_room_type_restriction_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_room_type_restriction_views.xml @@ -5,11 +5,31 @@ hotel.room.type.restriction + + + + + + + + + + + + + -