From 241c74f317493f8dc34e9852f32f245efa2cf690 Mon Sep 17 00:00:00 2001 From: Pablo Date: Mon, 15 Jul 2019 16:18:41 +0200 Subject: [PATCH 01/12] [UPD] Task 966 - calendar bells --- hotel_calendar/models/bus_hotel_calendar.py | 1 + hotel_calendar/models/inherited_hotel_reservation.py | 4 +++- .../static/src/js/views/hotel_calendar_controller.js | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hotel_calendar/models/bus_hotel_calendar.py b/hotel_calendar/models/bus_hotel_calendar.py index d1016ae29..f46b13598 100644 --- a/hotel_calendar/models/bus_hotel_calendar.py +++ b/hotel_calendar/models/bus_hotel_calendar.py @@ -52,6 +52,7 @@ class BusHotelCalendar(models.TransientModel): 'price_room_services_set': vals['price_room_services_set'], 'amount_total': vals['pending_amount'] + vals['invoices_paid'], 'real_dates': vals['real_dates'], + 'channel_type': vals['channel_type'], }, 'tooltip': { 'folio_name': vals['folio_name'], diff --git a/hotel_calendar/models/inherited_hotel_reservation.py b/hotel_calendar/models/inherited_hotel_reservation.py index 262a6f6c2..b99f2963d 100644 --- a/hotel_calendar/models/inherited_hotel_reservation.py +++ b/hotel_calendar/models/inherited_hotel_reservation.py @@ -94,7 +94,9 @@ class HotelReservation(models.Model): 'state': reserv['state'], 'price_room_services_set': reserv['price_room_services_set'], 'amount_total': reserv['amount_total'], - 'real_dates': [reserv['real_checkin'], reserv['real_checkout']]}) + 'real_dates': [reserv['real_checkin'], reserv['real_checkout']], + 'channel_type': reserv['channel_type'], + }) json_reservation_tooltips.update({ reserv['id']: { 'folio_name': reserv['folio_name'], diff --git a/hotel_calendar_channel_connector/static/src/js/views/hotel_calendar_controller.js b/hotel_calendar_channel_connector/static/src/js/views/hotel_calendar_controller.js index 996d133d2..266291905 100644 --- a/hotel_calendar_channel_connector/static/src/js/views/hotel_calendar_controller.js +++ b/hotel_calendar_channel_connector/static/src/js/views/hotel_calendar_controller.js @@ -76,7 +76,7 @@ var PMSHotelCalendarController = PMSCalendarController.include({ } else if (notif[1]['type'] === 'reservation') { var reserv = notif[1]['reservation']; - if (reserv['external_id']) { + if (reserv['channel_type'] == 'web') { if (notif[1]['action'] === 'create') { this._play_sound(this.SOUNDS.BOOK_NEW); } else if (notif[1]['action'] !== 'unlink' && reserv['state'] === 'cancelled') { From 8f6f41b5b1c7f964c886e275414ccb3d9cc29ab4 Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 18 Jul 2019 16:50:33 +0200 Subject: [PATCH 02/12] [UPD] Task 973 - binding for room types --- .../models/hotel_room_type/common.py | 14 +++++---- .../views/inherited_hotel_room_type_views.xml | 31 ++++++++++++++++--- .../models/hotel_room_type/exporter.py | 5 ++- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/hotel_channel_connector/models/hotel_room_type/common.py b/hotel_channel_connector/models/hotel_room_type/common.py index 8c5b6224a..43e50ab10 100644 --- a/hotel_channel_connector/models/hotel_room_type/common.py +++ b/hotel_channel_connector/models/hotel_room_type/common.py @@ -2,7 +2,6 @@ # 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 @@ -26,7 +25,6 @@ class ChannelHotelRoomType(models.Model): def _default_availability(self): return max(min(self.default_quota, self.default_max_avail), 0) - odoo_id = fields.Many2one(comodel_name='hotel.room.type', string='Room Type', required=True, @@ -172,10 +170,14 @@ class HotelRoomType(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 room type [%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): 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 814227f2d..dc2538a26 100644 --- a/hotel_channel_connector/views/inherited_hotel_room_type_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_room_type_views.xml @@ -5,20 +5,43 @@ hotel.room.type + + + + + + + + + + + + + - + + + + - + + + + -