mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] Getting books
This commit is contained in:
@@ -1,12 +1,10 @@
|
|||||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
import logging
|
import logging
|
||||||
import time
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||||
from odoo.tools.profiler import profile
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@@ -179,7 +177,6 @@ class HotelReservation(models.Model):
|
|||||||
def get_hcalendar_reservations_data(self, dfrom_dt, dto_dt, rooms):
|
def get_hcalendar_reservations_data(self, dfrom_dt, dto_dt, rooms):
|
||||||
rdfrom_dt = dfrom_dt + timedelta(days=1) # Ignore checkout
|
rdfrom_dt = dfrom_dt + timedelta(days=1) # Ignore checkout
|
||||||
rdfrom_str = rdfrom_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
rdfrom_str = rdfrom_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||||
dfrom_str = dfrom_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
|
||||||
dto_str = dto_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
dto_str = dto_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||||
self.env.cr.execute('''
|
self.env.cr.execute('''
|
||||||
SELECT
|
SELECT
|
||||||
@@ -201,11 +198,20 @@ class HotelReservation(models.Model):
|
|||||||
LEFT JOIN product_template AS pt ON pp.product_tmpl_id = pt.id
|
LEFT JOIN product_template AS pt ON pp.product_tmpl_id = pt.id
|
||||||
LEFT JOIN res_partner AS rp ON hf.partner_id = rp.id
|
LEFT JOIN res_partner AS rp ON hf.partner_id = rp.id
|
||||||
LEFT JOIN room_closure_reason as rcr ON hf.closure_reason_id = rcr.id
|
LEFT JOIN room_closure_reason as rcr ON hf.closure_reason_id = rcr.id
|
||||||
WHERE room_id IN %s AND ((checkin <= %s AND checkout >= %s) OR (checkin <= %s AND checkout >= %s) OR (checkin >= %s AND checkout <= %s))
|
WHERE room_id IN %s AND (
|
||||||
|
(checkin <= %s AND checkout >= %s AND checkout <= %s)
|
||||||
|
OR (checkin >= %s AND checkout <= %s)
|
||||||
|
OR (checkin >= %s AND checkin <= %s AND checkout >= %s)
|
||||||
|
OR (checkin <= %s AND checkout >= %s))
|
||||||
ORDER BY checkin DESC, checkout ASC, adults DESC, children DESC
|
ORDER BY checkin DESC, checkout ASC, adults DESC, children DESC
|
||||||
''', (tuple(rooms.ids), dto_str, rdfrom_str, dfrom_str, dto_str, dfrom_str, dto_str))
|
''', (tuple(rooms.ids),
|
||||||
|
rdfrom_str, rdfrom_str, dto_str,
|
||||||
|
rdfrom_str, dto_str,
|
||||||
|
rdfrom_str, dto_str, dto_str,
|
||||||
|
rdfrom_str, dto_str))
|
||||||
return self._hcalendar_reservation_data(self.env.cr.dictfetchall())
|
return self._hcalendar_reservation_data(self.env.cr.dictfetchall())
|
||||||
|
|
||||||
|
# Expensive if no data in cache model
|
||||||
@api.model
|
@api.model
|
||||||
def get_hcalendar_pricelist_data(self, dfrom_dt, dto_dt):
|
def get_hcalendar_pricelist_data(self, dfrom_dt, dto_dt):
|
||||||
pricelist_id = self.env['ir.default'].sudo().get(
|
pricelist_id = self.env['ir.default'].sudo().get(
|
||||||
|
|||||||
@@ -22,8 +22,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pms-menu {
|
#pms-menu {
|
||||||
padding: 0 0.2em !important;
|
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
background-color: #f8f8f8;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0 2.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pms-menu .input-group span, #pms-menu input {
|
#pms-menu .input-group span, #pms-menu input {
|
||||||
@@ -41,6 +43,32 @@
|
|||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pms-search {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hcal_widget {
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#multicalendar_panels {
|
||||||
|
background-color: white;
|
||||||
|
border-left: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-tabs > li > a {
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-tabs {
|
||||||
|
padding-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-default {
|
||||||
|
border-color: #f8f8f8;
|
||||||
|
}
|
||||||
|
|
||||||
button .led {
|
button .led {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|||||||
@@ -296,7 +296,6 @@ var PMSCalendarController = AbstractController.extend({
|
|||||||
$(this).find('.led').removeClass('led-enabled');
|
$(this).find('.led').removeClass('led-enabled');
|
||||||
}
|
}
|
||||||
active_calendar.addReservations(_.reject(self._multi_calendar._dataset['reservations'], {overbooking:false}));
|
active_calendar.addReservations(_.reject(self._multi_calendar._dataset['reservations'], {overbooking:false}));
|
||||||
_.defer(function(){ active_calendar._updateReservations(false); }); // Fix Possible Rows Displacements
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.renderer.$el.find('#pms-menu #btn_action_cancelled button').on('click', function(ev){
|
this.renderer.$el.find('#pms-menu #btn_action_cancelled button').on('click', function(ev){
|
||||||
@@ -310,7 +309,6 @@ var PMSCalendarController = AbstractController.extend({
|
|||||||
$(this).find('.led').removeClass('led-enabled');
|
$(this).find('.led').removeClass('led-enabled');
|
||||||
}
|
}
|
||||||
active_calendar.addReservations(_.reject(self._multi_calendar._dataset['reservations'], {cancelled:false}));
|
active_calendar.addReservations(_.reject(self._multi_calendar._dataset['reservations'], {cancelled:false}));
|
||||||
_.defer(function(){ active_calendar._updateReservations(false); }); // Fix Possible Rows Displacements
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.renderer.$el.find('#pms-menu #btn_action_divide button').on('click', function(ev){
|
this.renderer.$el.find('#pms-menu #btn_action_divide button').on('click', function(ev){
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ var HotelCalendarView = AbstractRenderer.extend({
|
|||||||
if (days === 'month') {
|
if (days === 'month') {
|
||||||
days = date_begin.daysInMonth();
|
days = date_begin.daysInMonth();
|
||||||
}
|
}
|
||||||
var date_end = date_begin.clone().add(days+1, 'd');
|
var date_end = date_begin.clone().add(days, 'd');
|
||||||
return [date_begin, date_end];
|
return [date_begin, date_end];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -41,42 +41,15 @@
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pms-search {
|
|
||||||
position: fixed;
|
|
||||||
z-index: 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pms-menu {
|
|
||||||
background-color: #f8f8f8;
|
|
||||||
height: 100%;
|
|
||||||
padding: 0 2.5em !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#hcal_widget {
|
|
||||||
max-height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#multicalendar_panels {
|
|
||||||
background-color: white;
|
|
||||||
border-left: 1px solid #ddd;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-tabs > li > a {
|
|
||||||
border-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-tabs {
|
|
||||||
padding-top: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-default {
|
|
||||||
border-color: #f8f8f8;
|
|
||||||
}
|
|
||||||
|
|
||||||
#cal-pag-prev-plus, #cal-pag-prev, #cal-pag-selector, #cal-pag-next, #cal-pag-next-plus {
|
#cal-pag-prev-plus, #cal-pag-prev, #cal-pag-selector, #cal-pag-next, #cal-pag-next-plus {
|
||||||
min-height: 0px;
|
min-height: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hcalendar-container {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
}
|
||||||
|
|
||||||
.table-reservations-header {
|
.table-reservations-header {
|
||||||
order: 1;
|
order: 1;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
@@ -493,6 +466,7 @@ td.hcal-cell-room-type-group-item {
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
font-size: x-small;
|
font-size: x-small;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
td.hcal-cell-room-type-group-item:last-child {
|
td.hcal-cell-room-type-group-item:last-child {
|
||||||
border-right-width: 2px;
|
border-right-width: 2px;
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ HotelCalendar.prototype = {
|
|||||||
if (reservations.length > 0 && !(reservations[0] instanceof HReservation)) {
|
if (reservations.length > 0 && !(reservations[0] instanceof HReservation)) {
|
||||||
console.warn("[HotelCalendar][addReservations] Invalid Reservation definition!");
|
console.warn("[HotelCalendar][addReservations] Invalid Reservation definition!");
|
||||||
} else {
|
} else {
|
||||||
|
var isCalendarEmpty = (this._reservations.length>0);
|
||||||
// Merge
|
// Merge
|
||||||
var addedReservations = [];
|
var addedReservations = [];
|
||||||
for (var r of reservations) {
|
for (var r of reservations) {
|
||||||
@@ -317,6 +318,7 @@ HotelCalendar.prototype = {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasCreatedExtraRows = false;
|
||||||
r = r.clone(); // HOT-FIX: Multi-Calendar Support
|
r = r.clone(); // HOT-FIX: Multi-Calendar Support
|
||||||
r.room = this.getRoom(r.room_id, r.overbooking || r.cancelled, r.id);
|
r.room = this.getRoom(r.room_id, r.overbooking || r.cancelled, r.id);
|
||||||
// need create a overbooking row?
|
// need create a overbooking row?
|
||||||
@@ -327,6 +329,7 @@ HotelCalendar.prototype = {
|
|||||||
cancelled: r.cancelled,
|
cancelled: r.cancelled,
|
||||||
});
|
});
|
||||||
this.createExtraRoomRow(r.room);
|
this.createExtraRoomRow(r.room);
|
||||||
|
hasCreatedExtraRows = true;
|
||||||
} else {
|
} else {
|
||||||
console.warn(`Can't found the room '${r.room_id}' for the reservation '${r.id}' (${r.title})!`);
|
console.warn(`Can't found the room '${r.room_id}' for the reservation '${r.id}' (${r.title})!`);
|
||||||
continue;
|
continue;
|
||||||
@@ -356,7 +359,7 @@ HotelCalendar.prototype = {
|
|||||||
_.defer(function(reservs){
|
_.defer(function(reservs){
|
||||||
// Update offsets (New Rooms change positions?)
|
// Update offsets (New Rooms change positions?)
|
||||||
this._updateOffsets();
|
this._updateOffsets();
|
||||||
|
|
||||||
var unusedZones = this._createUnusedZones(reservs);
|
var unusedZones = this._createUnusedZones(reservs);
|
||||||
// Add Unused Zones
|
// Add Unused Zones
|
||||||
this._reservations = this._reservations.concat(unusedZones);
|
this._reservations = this._reservations.concat(unusedZones);
|
||||||
@@ -928,17 +931,21 @@ HotelCalendar.prototype = {
|
|||||||
|
|
||||||
var scrollThrottle = _.throttle(this._updateOBIndicators.bind(this), 100);
|
var scrollThrottle = _.throttle(this._updateOBIndicators.bind(this), 100);
|
||||||
|
|
||||||
|
|
||||||
|
this.edivcontainer = document.createElement("div");
|
||||||
|
this.edivcontainer.classList.add('hcalendar-container');
|
||||||
|
|
||||||
// Reservations Table
|
// Reservations Table
|
||||||
this.edivrh = document.createElement("div");
|
this.edivrh = document.createElement("div");
|
||||||
this.edivrh.classList.add('table-reservations-header');
|
this.edivrh.classList.add('table-reservations-header');
|
||||||
this.e.appendChild(this.edivrh);
|
this.edivcontainer.appendChild(this.edivrh);
|
||||||
this.etableHeader = document.createElement("table");
|
this.etableHeader = document.createElement("table");
|
||||||
this.etableHeader.classList.add('hcal-table');
|
this.etableHeader.classList.add('hcal-table');
|
||||||
this.etableHeader.classList.add('noselect');
|
this.etableHeader.classList.add('noselect');
|
||||||
this.edivrh.appendChild(this.etableHeader);
|
this.edivrh.appendChild(this.etableHeader);
|
||||||
this.edivr = document.createElement("div");
|
this.edivr = document.createElement("div");
|
||||||
this.edivr.classList.add('table-reservations');
|
this.edivr.classList.add('table-reservations');
|
||||||
this.e.appendChild(this.edivr);
|
this.edivcontainer.appendChild(this.edivr);
|
||||||
this.etable = document.createElement("table");
|
this.etable = document.createElement("table");
|
||||||
this.etable.classList.add('hcal-table');
|
this.etable.classList.add('hcal-table');
|
||||||
this.etable.classList.add('noselect');
|
this.etable.classList.add('noselect');
|
||||||
@@ -947,14 +954,14 @@ HotelCalendar.prototype = {
|
|||||||
// Detail Calcs Table
|
// Detail Calcs Table
|
||||||
this.edivch = document.createElement("div");
|
this.edivch = document.createElement("div");
|
||||||
this.edivch.classList.add('table-calcs-header');
|
this.edivch.classList.add('table-calcs-header');
|
||||||
this.e.appendChild(this.edivch);
|
this.edivcontainer.appendChild(this.edivch);
|
||||||
this.edtableHeader = document.createElement("table");
|
this.edtableHeader = document.createElement("table");
|
||||||
this.edtableHeader.classList.add('hcal-table');
|
this.edtableHeader.classList.add('hcal-table');
|
||||||
this.edtableHeader.classList.add('noselect');
|
this.edtableHeader.classList.add('noselect');
|
||||||
this.edivch.appendChild(this.edtableHeader);
|
this.edivch.appendChild(this.edtableHeader);
|
||||||
this.edivc = document.createElement("div");
|
this.edivc = document.createElement("div");
|
||||||
this.edivc.classList.add('table-calcs');
|
this.edivc.classList.add('table-calcs');
|
||||||
this.e.appendChild(this.edivc);
|
this.edivcontainer.appendChild(this.edivc);
|
||||||
this.edtable = document.createElement("table");
|
this.edtable = document.createElement("table");
|
||||||
this.edtable.classList.add('hcal-table');
|
this.edtable.classList.add('hcal-table');
|
||||||
this.edtable.classList.add('noselect');
|
this.edtable.classList.add('noselect');
|
||||||
@@ -965,6 +972,8 @@ HotelCalendar.prototype = {
|
|||||||
});
|
});
|
||||||
observer.observe(this.edivr, { childList: true });
|
observer.observe(this.edivr, { childList: true });
|
||||||
|
|
||||||
|
this.e.appendChild(this.edivcontainer);
|
||||||
|
|
||||||
this._updateView();
|
this._updateView();
|
||||||
//_.defer(function(self){ self._updateView(); }, this);
|
//_.defer(function(self){ self._updateView(); }, this);
|
||||||
this._tableCreated = true;
|
this._tableCreated = true;
|
||||||
@@ -1444,7 +1453,7 @@ HotelCalendar.prototype = {
|
|||||||
warnDiv.classList.add('hcal-warn-ob-indicator');
|
warnDiv.classList.add('hcal-warn-ob-indicator');
|
||||||
warnDiv.style.borderTopLeftRadius = warnDiv.style.borderTopRightRadius = "50px";
|
warnDiv.style.borderTopLeftRadius = warnDiv.style.borderTopRightRadius = "50px";
|
||||||
warnDiv.dataset.hcalReservationObjId = reserv.id;
|
warnDiv.dataset.hcalReservationObjId = reserv.id;
|
||||||
this.e.appendChild(warnDiv);
|
this.edivcontainer.appendChild(warnDiv);
|
||||||
var warnComputedStyle = window.getComputedStyle(warnDiv, null);
|
var warnComputedStyle = window.getComputedStyle(warnDiv, null);
|
||||||
warnDiv.style.top = `${mainBounds.height - eOffset.top - parseInt(warnComputedStyle.getPropertyValue("height"), 10)}px`;
|
warnDiv.style.top = `${mainBounds.height - eOffset.top - parseInt(warnComputedStyle.getPropertyValue("height"), 10)}px`;
|
||||||
warnDiv.style.left = `${(bounds.left + (bounds.right - bounds.left)/2.0 - parseInt(warnComputedStyle.getPropertyValue("width"), 10)/2.0) - mainBounds.left}px`;
|
warnDiv.style.left = `${(bounds.left + (bounds.right - bounds.left)/2.0 - parseInt(warnComputedStyle.getPropertyValue("width"), 10)/2.0) - mainBounds.left}px`;
|
||||||
@@ -1458,7 +1467,7 @@ HotelCalendar.prototype = {
|
|||||||
warnDiv.style.borderBottomLeftRadius = warnDiv.style.borderBottomRightRadius = "50px";
|
warnDiv.style.borderBottomLeftRadius = warnDiv.style.borderBottomRightRadius = "50px";
|
||||||
warnDiv.style.top = `${mainBounds.top - eOffset.top}px`;
|
warnDiv.style.top = `${mainBounds.top - eOffset.top}px`;
|
||||||
warnDiv.dataset.hcalReservationObjId = reserv.id;
|
warnDiv.dataset.hcalReservationObjId = reserv.id;
|
||||||
this.e.appendChild(warnDiv);
|
this.edivcontainer.appendChild(warnDiv);
|
||||||
var warnComputedStyle = window.getComputedStyle(warnDiv, null);
|
var warnComputedStyle = window.getComputedStyle(warnDiv, null);
|
||||||
warnDiv.style.left = `${(bounds.left + (bounds.right - bounds.left)/2.0 - parseInt(warnComputedStyle.getPropertyValue("width"), 10)/2.0) - mainBounds.left}px`;
|
warnDiv.style.left = `${(bounds.left + (bounds.right - bounds.left)/2.0 - parseInt(warnComputedStyle.getPropertyValue("width"), 10)/2.0) - mainBounds.left}px`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user