diff --git a/hotel_channel_connector/models/hotel_room_type/common.py b/hotel_channel_connector/models/hotel_room_type/common.py index 50e76c605..ff5b3da4f 100644 --- a/hotel_channel_connector/models/hotel_room_type/common.py +++ b/hotel_channel_connector/models/hotel_room_type/common.py @@ -2,6 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, models, fields, _ +from odoo.exceptions import UserError from odoo.exceptions import ValidationError from odoo.addons import decimal_precision as dp from odoo.addons.queue_job.job import job @@ -111,6 +112,27 @@ class HotelRoomType(models.Model): ], limit=1) return restriction + @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_action').read()[0] + action['views'] = [(self.env.ref('hotel_channel_connector.channel_hotel_room_type_view_form').id, 'form')] + 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['target'] = 'new' + return action + + @api.multi + def sync_from_channel(self): + channel_bind_ids = self.mapped('channel_bind_ids') + msg = _("Synchronize room types from the channel manager is not yet implementet.") + raise UserError(msg) + + class BindingHotelRoomTypeListener(Component): _name = 'binding.hotel.room.type.listener' _inherit = 'base.connector.listener' 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 82acb2a32..ef5e43c9d 100644 --- a/hotel_channel_connector/views/channel_hotel_room_type_views.xml +++ b/hotel_channel_connector/views/channel_hotel_room_type_views.xml @@ -8,9 +8,10 @@
- + + @@ -33,4 +34,12 @@ + + Hotel Channel Connector Bindings + channel.hotel.room.type + form + tree,form + form + [] + diff --git a/hotel_channel_connector/views/inherited_hotel_room_type_views.xml b/hotel_channel_connector/views/inherited_hotel_room_type_views.xml index ee768dbe5..1721a1731 100644 --- a/hotel_channel_connector/views/inherited_hotel_room_type_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_room_type_views.xml @@ -5,23 +5,16 @@ hotel.room.type - - + +