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 64fc0fbed..94e57842d 100644 --- a/hotel_channel_connector/models/hotel_room_type_restriction/common.py +++ b/hotel_channel_connector/models/hotel_room_type_restriction/common.py @@ -1,7 +1,8 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, models, fields +from odoo import api, models, fields, _ +from odoo.exceptions import UserError from odoo.addons.queue_job.job import job from odoo.addons.component.core import Component from odoo.addons.component_event import skip_if @@ -78,6 +79,31 @@ class HotelRoomTypeRestriction(models.Model): names.append((name[0], name[1])) return names + @api.multi + def open_channel_bind_ids(self): + channel_bind_ids = self.mapped('channel_bind_ids') + action = self.env.ref('hotel_channel_connector.channel_hotel_room_type_restriction_action').read()[0] + action['views'] = [(self.env.ref('hotel_channel_connector.channel_hotel_room_type_restriction_view_form').id, 'form')] + action['target'] = 'new' + if len(channel_bind_ids) == 1: + action['res_id'] = channel_bind_ids.ids[0] + elif len(channel_bind_ids) > 1: + # WARNING: more than one binding is currently not expected + action['domain'] = [('id', 'in', channel_bind_ids.ids)] + else: + action['context'] = { + 'default_odoo_id': self.id, + 'default_name': self.name, + } + return action + + @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 room type [%s] should be delete from the channel manager.") % channel_bind_ids.get_external_id + raise UserError(msg) + class BindingHotelRoomTypeListener(Component): _name = 'binding.hotel.room.type.restriction.listener' _inherit = 'base.connector.listener' diff --git a/hotel_channel_connector/views/channel_hotel_room_type_restriction_views.xml b/hotel_channel_connector/views/channel_hotel_room_type_restriction_views.xml index f7b010e7a..63ed64a71 100644 --- a/hotel_channel_connector/views/channel_hotel_room_type_restriction_views.xml +++ b/hotel_channel_connector/views/channel_hotel_room_type_restriction_views.xml @@ -27,4 +27,13 @@ + + Hotel Channel Connector Bindings + channel.hotel.room.type.restriction + form + tree,form + form + [] + + diff --git a/hotel_channel_connector/views/channel_hotel_room_type_views.xml b/hotel_channel_connector/views/channel_hotel_room_type_views.xml index a1ba359f1..2f243ec66 100644 --- a/hotel_channel_connector/views/channel_hotel_room_type_views.xml +++ b/hotel_channel_connector/views/channel_hotel_room_type_views.xml @@ -5,7 +5,7 @@ channel.hotel.room.type.form channel.hotel.room.type -
+ 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 4917a4d63..34aa9369d 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,19 +5,22 @@ hotel.room.type.restriction - - - - - - - - - - - - - + + +