From 09e6cda9182205de9650a9cc8c75d2bb7e5a0641 Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 21 Feb 2019 19:44:09 +0100 Subject: [PATCH] [WIP] show channel availability in calendar management --- .../lib/hcalendar/js/hcalendar_management.js | 20 ++++++++++++++++++- .../inherited_hotel_calendar_management.py | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar_management.js b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar_management.js index 04c5ae2c0..31f834549 100644 --- a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar_management.js +++ b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar_management.js @@ -217,6 +217,7 @@ HotelCalendarManagement.prototype = { row = table.insertRow(); row.setAttribute('name', 'avail'); row.style.display = 'none'; + cell = row.insertCell(); cell.setAttribute('colspan', '2'); telm = document.createElement("input"); @@ -229,8 +230,9 @@ HotelCalendarManagement.prototype = { telm.classList.add('hcal-management-input'); telm.addEventListener('change', function(ev){ $this.onInputChange(ev, this); }, false); cell.appendChild(telm); + cell = row.insertCell(); - cell.setAttribute('colspan', '2'); + cell.setAttribute('colspan', '1'); telm = document.createElement("input"); telm.setAttribute('id', this._sanitizeId(`MAX_AVAIL_${roomId}_${dateShortStr}`)); telm.setAttribute('name', 'max_avail'); @@ -242,6 +244,21 @@ HotelCalendarManagement.prototype = { telm.addEventListener('change', function(ev){ $this.onInputChange(ev, this); }, false); cell.appendChild(telm); + cell = row.insertCell(); + cell.setAttribute('colspan', '1'); + telm = document.createElement("input"); + telm.setAttribute('id', this._sanitizeId(`CHANNEL_AVAIL_${roomId}_${dateShortStr}`)); + telm.setAttribute('name', 'channel_avail'); + telm.setAttribute('type', 'edit'); + telm.setAttribute('title', this._t('Channel Availability')); + telm.setAttribute('readonly', 'readonly'); + telm.setAttribute('disabled', 'disabled'); + telm.style.backgroundColor = 'lightgray'; + telm.value = telm.dataset.orgValue = 0; + telm.dataset.hcalParentCell = parentCell.getAttribute('id'); + telm.classList.add('hcal-management-input'); + cell.appendChild(telm); + row = table.insertRow(); row.setAttribute('name', 'rest_a'); cell = row.insertCell(); @@ -725,6 +742,7 @@ HotelCalendarManagement.prototype = { var inputIds = [ `QUOTA_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.quota, `MAX_AVAIL_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.max_avail, + `CHANNEL_AVAIL_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.channel_avail, `NO_OTA_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.no_ota ]; diff --git a/hotel_calendar_channel_connector/models/inherited_hotel_calendar_management.py b/hotel_calendar_channel_connector/models/inherited_hotel_calendar_management.py index a811de376..d707c1116 100644 --- a/hotel_calendar_channel_connector/models/inherited_hotel_calendar_management.py +++ b/hotel_calendar_channel_connector/models/inherited_hotel_calendar_management.py @@ -38,6 +38,7 @@ class HotelCalendarManagement(models.TransientModel): 'no_ota': avail and avail.no_ota or False, 'quota': avail and avail.quota or -1, 'max_avail': avail and avail.max_avail or -1, + 'channel_avail': avail and avail.channel_bind_ids.channel_avail or room_type.channel_bind_ids.default_availability } @api.model