mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] Refactor Code
This commit is contained in:
@@ -40,33 +40,34 @@ class BusHotelCalendar(models.TransientModel):
|
|||||||
'userid': user_id.id,
|
'userid': user_id.id,
|
||||||
'reservation': {
|
'reservation': {
|
||||||
'room_id': vals['room_id'],
|
'room_id': vals['room_id'],
|
||||||
'reserv_id': vals['reserv_id'],
|
'id': vals['reserv_id'],
|
||||||
'partner_name': vals['partner_name'],
|
'name': vals['partner_name'],
|
||||||
'adults': vals['adults'],
|
'adults': vals['adults'],
|
||||||
'childer': vals['children'],
|
'childer': vals['children'],
|
||||||
'checkin': vals['checkin'],
|
'checkin': vals['checkin'],
|
||||||
'checkout': vals['checkout'],
|
'checkout': vals['checkout'],
|
||||||
'folio_id': vals['folio_id'],
|
'folio_id': vals['folio_id'],
|
||||||
'reserve_color': vals['reserve_color'],
|
'bgcolor': vals['reserve_color'],
|
||||||
'reserve_color_text': vals['reserve_color_text'],
|
'color': vals['reserve_color_text'],
|
||||||
'splitted': vals['splitted'],
|
'splitted': vals['splitted'],
|
||||||
'parent_reservation': vals['parent_reservation'],
|
'parent_reservation': vals['parent_reservation'],
|
||||||
'room_name': vals['room_name'],
|
'room_name': vals['room_name'],
|
||||||
'state': vals['state'],
|
'state': vals['state'],
|
||||||
'only_read': False,
|
'only_read': False,
|
||||||
'fix_days': vals['fix_days'],
|
'fix_days': vals['fix_days'],
|
||||||
'fix_rooms': False,
|
'fix_room': False,
|
||||||
'overbooking': vals['overbooking'],
|
'overbooking': vals['overbooking'],
|
||||||
|
'real_dates': vals['real_dates'],
|
||||||
},
|
},
|
||||||
'tooltip': [
|
'tooltip': {
|
||||||
vals['partner_name'],
|
'name': vals['partner_name'],
|
||||||
vals['partner_phone'],
|
'phone': vals['partner_phone'],
|
||||||
vals['checkin'],
|
'checkin': vals['checkin'],
|
||||||
num_split,
|
'num_split': num_split,
|
||||||
vals['price'],
|
'amount_total': vals['amount_total'],
|
||||||
vals['reservation_type'] if 'reservation_type' in vals else 'normal',
|
'type': vals['reservation_type'] if 'reservation_type' in vals else 'normal',
|
||||||
vals['out_service_description'] if 'out_service_description' in vals else _('No reason given'),
|
'out_service_description': vals['out_service_description'] if 'out_service_description' in vals else _('No reason given'),
|
||||||
]
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
|||||||
@@ -78,25 +78,25 @@ class HotelReservation(models.Model):
|
|||||||
json_reservations = []
|
json_reservations = []
|
||||||
json_reservation_tooltips = {}
|
json_reservation_tooltips = {}
|
||||||
for reserv in reservations:
|
for reserv in reservations:
|
||||||
json_reservations.append([
|
json_reservations.append({
|
||||||
reserv.room_id.id,
|
'room_id': reserv.room_id.id,
|
||||||
reserv.id,
|
'id': reserv.id,
|
||||||
reserv.folio_id.closure_reason_id.name or _('Out of service') if reserv.folio_id.reservation_type == 'out'
|
'name': reserv.folio_id.closure_reason_id.name or _('Out of service') if reserv.folio_id.reservation_type == 'out'
|
||||||
else reserv.folio_id.partner_id.name,
|
else reserv.folio_id.partner_id.name,
|
||||||
reserv.adults,
|
'adults': reserv.adults,
|
||||||
reserv.children,
|
'childrens': reserv.children,
|
||||||
reserv.checkin,
|
'checkin': reserv.checkin,
|
||||||
reserv.checkout,
|
'checkout': reserv.checkout,
|
||||||
reserv.folio_id.id,
|
'folio_id': reserv.folio_id.id,
|
||||||
reserv.reserve_color,
|
'bgcolor': reserv.reserve_color,
|
||||||
reserv.reserve_color_text,
|
'color': reserv.reserve_color_text,
|
||||||
reserv.splitted,
|
'splitted': reserv.splitted,
|
||||||
reserv.parent_reservation and reserv.parent_reservation.id
|
'parent_reservation': reserv.parent_reservation and reserv.parent_reservation.id or False,
|
||||||
or False,
|
'read_only': False, # Read-Only
|
||||||
False, # Read-Only
|
'fix_days': reserv.splitted, # Fix Days
|
||||||
reserv.splitted, # Fix Days
|
'fix_room': False, # Fix Rooms
|
||||||
False, # Fix Rooms
|
'overbooking': reserv.overbooking,
|
||||||
reserv.overbooking])
|
'real_dates': reserv.get_real_checkin_checkout()})
|
||||||
num_split = 0
|
num_split = 0
|
||||||
if reserv.splitted:
|
if reserv.splitted:
|
||||||
master_reserv = reserv.parent_reservation or reserv
|
master_reserv = reserv.parent_reservation or reserv
|
||||||
@@ -107,16 +107,17 @@ class HotelReservation(models.Model):
|
|||||||
('splitted', '=', True),
|
('splitted', '=', True),
|
||||||
])
|
])
|
||||||
json_reservation_tooltips.update({
|
json_reservation_tooltips.update({
|
||||||
reserv.id: [
|
reserv.id: {
|
||||||
_('Out of service') if reserv.folio_id.reservation_type == 'out' else reserv.folio_id.partner_id.name,
|
'name': _('Out of service') if reserv.folio_id.reservation_type == 'out' else reserv.folio_id.partner_id.name,
|
||||||
reserv.folio_id.partner_id.mobile or
|
'phone': reserv.folio_id.partner_id.mobile or
|
||||||
reserv.folio_id.partner_id.phone or _('Undefined'),
|
reserv.folio_id.partner_id.phone or _('Undefined'),
|
||||||
reserv.checkin,
|
'checkin': reserv.checkin,
|
||||||
num_split,
|
'num_split': num_split,
|
||||||
reserv.folio_id.amount_total,
|
'amount_total': reserv.folio_id.amount_total,
|
||||||
reserv.reservation_type or 'normal',
|
'type': reserv.reservation_type or 'normal',
|
||||||
reserv.out_service_description or _('No reason given'),
|
'out_service_description': reserv.out_service_description or
|
||||||
]
|
_('No reason given'),
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return (json_reservations, json_reservation_tooltips)
|
return (json_reservations, json_reservation_tooltips)
|
||||||
|
|
||||||
@@ -163,12 +164,12 @@ class HotelReservation(models.Model):
|
|||||||
def _hcalendar_event_data(self, events):
|
def _hcalendar_event_data(self, events):
|
||||||
json_events = []
|
json_events = []
|
||||||
for event in events:
|
for event in events:
|
||||||
json_events.append([
|
json_events.append({
|
||||||
event.id,
|
'id': event.id,
|
||||||
event.name,
|
'name': event.name,
|
||||||
event.start,
|
'date': event.start,
|
||||||
event.location,
|
'location': event.location,
|
||||||
])
|
})
|
||||||
return json_events
|
return json_events
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -341,39 +342,46 @@ class HotelReservation(models.Model):
|
|||||||
|
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def generate_bus_values(self, naction, ntype, ntitle=''):
|
||||||
|
self.ensure_one()
|
||||||
|
return {
|
||||||
|
'action': naction,
|
||||||
|
'type': ntype,
|
||||||
|
'title': ntitle,
|
||||||
|
'room_id': self.room_id.id,
|
||||||
|
'reserv_id': self.id,
|
||||||
|
'partner_name': (self.closure_reason_id.name or _('Out of service'))
|
||||||
|
if self.reservation_type == 'out' else self.partner_id.name,
|
||||||
|
'adults': self.adults,
|
||||||
|
'children': self.children,
|
||||||
|
'checkin': self.checkin,
|
||||||
|
'checkout': self.checkout,
|
||||||
|
'folio_id': self.folio_id.id,
|
||||||
|
'reserve_color': self.reserve_color,
|
||||||
|
'reserve_color_text': self.reserve_color_text,
|
||||||
|
'splitted': self.splitted,
|
||||||
|
'parent_reservation': self.parent_reservation and
|
||||||
|
self.parent_reservation.id or 0,
|
||||||
|
'room_name': self.room_id.name,
|
||||||
|
'partner_phone': self.partner_id.mobile
|
||||||
|
or self.partner_id.phone or _('Undefined'),
|
||||||
|
'state': self.state,
|
||||||
|
'fix_days': self.splitted,
|
||||||
|
'overbooking': self.overbooking,
|
||||||
|
'amount_total': self.folio_id.amount_total,
|
||||||
|
'reservation_type': self.reservation_type or 'normal',
|
||||||
|
'closure_reason_id': self.closure_reason_id,
|
||||||
|
'out_service_description': self.out_service_description or _('No reason given'),
|
||||||
|
'real_dates': self.get_real_checkin_checkout(),
|
||||||
|
}
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def send_bus_notification(self, naction, ntype, ntitle=''):
|
def send_bus_notification(self, naction, ntype, ntitle=''):
|
||||||
hotel_cal_obj = self.env['bus.hotel.calendar']
|
hotel_cal_obj = self.env['bus.hotel.calendar']
|
||||||
for record in self:
|
for record in self:
|
||||||
hotel_cal_obj.send_reservation_notification({
|
hotel_cal_obj.send_reservation_notification(
|
||||||
'action': naction,
|
record.generate_bus_values(naction, ntype, ntitle))
|
||||||
'type': ntype,
|
|
||||||
'title': ntitle,
|
|
||||||
'room_id': record.room_id.id,
|
|
||||||
'reserv_id': record.id,
|
|
||||||
'partner_name': (record.closure_reason_id.name or _('Out of service'))
|
|
||||||
if record.reservation_type == 'out' else record.partner_id.name,
|
|
||||||
'adults': record.adults,
|
|
||||||
'children': record.children,
|
|
||||||
'checkin': record.checkin,
|
|
||||||
'checkout': record.checkout,
|
|
||||||
'folio_id': record.folio_id.id,
|
|
||||||
'reserve_color': record.reserve_color,
|
|
||||||
'reserve_color_text': record.reserve_color_text,
|
|
||||||
'splitted': record.splitted,
|
|
||||||
'parent_reservation': record.parent_reservation and
|
|
||||||
record.parent_reservation.id or 0,
|
|
||||||
'room_name': record.room_id.name,
|
|
||||||
'partner_phone': record.partner_id.mobile
|
|
||||||
or record.partner_id.phone or _('Undefined'),
|
|
||||||
'state': record.state,
|
|
||||||
'fix_days': record.splitted,
|
|
||||||
'overbooking': record.overbooking,
|
|
||||||
'price': record.folio_id.amount_total,
|
|
||||||
'reservation_type': record.reservation_type,
|
|
||||||
'closure_reason_id': record.closure_reason_id,
|
|
||||||
'out_service_description': record.out_service_description or _('No reason given'),
|
|
||||||
})
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def swap_reservations(self, fromReservsIds, toReservsIds):
|
def swap_reservations(self, fromReservsIds, toReservsIds):
|
||||||
@@ -431,9 +439,7 @@ class HotelReservation(models.Model):
|
|||||||
'reserve_color' in vals or \
|
'reserve_color' in vals or \
|
||||||
'reserve_color_text' in vals or 'product_id' in vals or \
|
'reserve_color_text' in vals or 'product_id' in vals or \
|
||||||
'parent_reservation' in vals or 'overbooking' in vals:
|
'parent_reservation' in vals or 'overbooking' in vals:
|
||||||
_logger.info("PASA RESERV WRITE")
|
|
||||||
for record in self:
|
for record in self:
|
||||||
_logger.info("PASA RESERV WRITE 22")
|
|
||||||
record.send_bus_notification(
|
record.send_bus_notification(
|
||||||
'write',
|
'write',
|
||||||
(record.state == 'cancelled') and 'warn' or 'notify',
|
(record.state == 'cancelled') and 'warn' or 'notify',
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ var PMSCalendarController = AbstractController.extend({
|
|||||||
onLoadCalendarSettings: '_onLoadCalendarSettings',
|
onLoadCalendarSettings: '_onLoadCalendarSettings',
|
||||||
onLoadViewFilters: '_onLoadViewFilters',
|
onLoadViewFilters: '_onLoadViewFilters',
|
||||||
onUpdateButtonsCounter: '_onUpdateButtonsCounter',
|
onUpdateButtonsCounter: '_onUpdateButtonsCounter',
|
||||||
onReloadCalendar: '_onReloadCalendar',
|
|
||||||
onSwapReservations: '_onSwapReservations',
|
onSwapReservations: '_onSwapReservations',
|
||||||
onViewAttached: '_onViewAttached',
|
onViewAttached: '_onViewAttached',
|
||||||
onApplyFilters: '_onApplyFilters',
|
onApplyFilters: '_onApplyFilters',
|
||||||
@@ -118,29 +117,13 @@ var PMSCalendarController = AbstractController.extend({
|
|||||||
rooms.push(nroom);
|
rooms.push(nroom);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Not read this... do the change!!
|
|
||||||
var reservs = [];
|
var reservs = [];
|
||||||
for (var r of results['reservations']) {
|
for (var r of results['reservations']) {
|
||||||
var nreserv = new HReservation({
|
var nreserv = new HReservation(self._generate_reservation_obj_values(r));
|
||||||
'id': r[1],
|
nreserv.addUserData({
|
||||||
'room_id': r[0],
|
'folio_id': r['folio_id'],
|
||||||
'title': r[2],
|
'parent_reservation': r['parent_reservation']
|
||||||
'adults': r[3],
|
|
||||||
'childrens': r[4],
|
|
||||||
'startDate': HotelCalendar.toMomentUTC(r[5], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
|
||||||
'endDate': HotelCalendar.toMomentUTC(r[6], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
|
||||||
'color': r[8],
|
|
||||||
'colorText': r[9],
|
|
||||||
'splitted': r[10],
|
|
||||||
'readOnly': r[12],
|
|
||||||
'fixDays': r[13],
|
|
||||||
'fixRooms': r[14],
|
|
||||||
'unusedZone': false,
|
|
||||||
'linkedId': false,
|
|
||||||
'overbooking': r[15],
|
|
||||||
});
|
});
|
||||||
nreserv.addUserData({'folio_id': r[7]});
|
|
||||||
nreserv.addUserData({'parent_reservation': r[11]});
|
|
||||||
reservs.push(nreserv);
|
reservs.push(nreserv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,26 +193,11 @@ var PMSCalendarController = AbstractController.extend({
|
|||||||
this.model.get_calendar_data(oparams).then(function(results){
|
this.model.get_calendar_data(oparams).then(function(results){
|
||||||
var reservs = [];
|
var reservs = [];
|
||||||
for (var r of results['reservations']) {
|
for (var r of results['reservations']) {
|
||||||
var nreserv = new HReservation({
|
var nreserv = new HReservation(self._generate_reservation_obj_values(r));
|
||||||
'id': r[1],
|
nreserv.addUserData({
|
||||||
'room_id': r[0],
|
'folio_id': r['folio_id'],
|
||||||
'title': r[2],
|
'parent_reservation': r['parent_reservation']
|
||||||
'adults': r[3],
|
|
||||||
'childrens': r[4],
|
|
||||||
'startDate': HotelCalendar.toMomentUTC(r[5], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
|
||||||
'endDate': HotelCalendar.toMomentUTC(r[6], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
|
||||||
'color': r[8],
|
|
||||||
'colorText': r[9],
|
|
||||||
'splitted': r[10],
|
|
||||||
'readOnly': r[12] || false,
|
|
||||||
'fixDays': r[13] || false,
|
|
||||||
'fixRooms': r[14] || false,
|
|
||||||
'unusedZone': false,
|
|
||||||
'linkedId': false,
|
|
||||||
'overbooking': r[15],
|
|
||||||
});
|
});
|
||||||
nreserv.addUserData({'folio_id': r[7]});
|
|
||||||
nreserv.addUserData({'parent_reservation': r[11]});
|
|
||||||
reservs.push(nreserv);
|
reservs.push(nreserv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,6 +627,28 @@ var PMSCalendarController = AbstractController.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_generate_reservation_obj_values: function(reserv) {
|
||||||
|
return {
|
||||||
|
'id': reserv['id'],
|
||||||
|
'room_id': reserv['room_id'],
|
||||||
|
'title': reserv['name'],
|
||||||
|
'adults': reserv['adults'],
|
||||||
|
'childrens': reserv['childrens'],
|
||||||
|
'startDate': HotelCalendar.toMomentUTC(reserv['checkin'], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||||
|
'endDate': HotelCalendar.toMomentUTC(reserv['checkout'], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||||
|
'color': reserv['bgcolor'],
|
||||||
|
'colorText': reserv['color'],
|
||||||
|
'splitted': reserv['splitted'] || false,
|
||||||
|
'readOnly': reserv['read_only'] || false,
|
||||||
|
'fixDays': reserv['fix_days'] || false,
|
||||||
|
'fixRooms': reserv['fix_room'],
|
||||||
|
'unusedZone': false,
|
||||||
|
'linkedId': false,
|
||||||
|
'overbooking': reserv['overbooking'],
|
||||||
|
'realDates': reserv['real_dates']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_onBusNotification: function(notifications) {
|
_onBusNotification: function(notifications) {
|
||||||
var need_reload_pricelists = false;
|
var need_reload_pricelists = false;
|
||||||
var need_update_counters = false;
|
var need_update_counters = false;
|
||||||
@@ -687,34 +677,17 @@ var PMSCalendarController = AbstractController.extend({
|
|||||||
|
|
||||||
// Create/Update/Delete reservation
|
// Create/Update/Delete reservation
|
||||||
if (notif[1]['action'] === 'unlink' || reserv['state'] === 'cancelled') {
|
if (notif[1]['action'] === 'unlink' || reserv['state'] === 'cancelled') {
|
||||||
this._multi_calendar.remove_reservation(reserv['reserv_id']);
|
this._multi_calendar.remove_reservation(reserv['id']);
|
||||||
this._multi_calendar._reserv_tooltips = _.pick(this._multi_calendar._reserv_tooltips, function(value, key, obj){ return key != reserv['reserv_id']; });
|
this._multi_calendar._reserv_tooltips = _.pick(this._multi_calendar._reserv_tooltips, function(value, key, obj){ return key != reserv['id']; });
|
||||||
nreservs = _.reject(nreservs, function(item){ return item.id == reserv['reserv_id']; });
|
nreservs = _.reject(nreservs, function(item){ return item.id == reserv['id']; });
|
||||||
} else {
|
} else {
|
||||||
nreservs = _.reject(nreservs, {'id': reserv['reserv_id']}); // Only like last changes
|
nreservs = _.reject(nreservs, {'id': reserv['id']}); // Only like last changes
|
||||||
var nreserv = new HReservation({
|
var nreserv = new HReservation(this._generate_reservation_obj_values(reserv));
|
||||||
'id': reserv['reserv_id'],
|
|
||||||
'room_id': reserv['room_id'],
|
|
||||||
'title': reserv['partner_name'],
|
|
||||||
'adults': reserv['adults'],
|
|
||||||
'childrens': reserv['children'],
|
|
||||||
'startDate': HotelCalendar.toMomentUTC(reserv['checkin'], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
|
||||||
'endDate': HotelCalendar.toMomentUTC(reserv['checkout'], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
|
||||||
'color': reserv['reserve_color'],
|
|
||||||
'colorText': reserv['reserve_color_text'],
|
|
||||||
'splitted': reserv['splitted'],
|
|
||||||
'readOnly': reserv['read_only'],
|
|
||||||
'fixDays': reserv['fix_days'],
|
|
||||||
'fixRooms': reserv['fix_rooms'],
|
|
||||||
'unusedZone': false,
|
|
||||||
'linkedId': false,
|
|
||||||
'overbooking': reserv['overbooking'],
|
|
||||||
});
|
|
||||||
nreserv.addUserData({
|
nreserv.addUserData({
|
||||||
'folio_id': reserv['folio_id'],
|
'folio_id': reserv['folio_id'],
|
||||||
'parent_reservation': reserv['parent_reservation'],
|
'parent_reservation': reserv['parent_reservation'],
|
||||||
});
|
});
|
||||||
this._multi_calendar._reserv_tooltips[reserv['reserv_id']] = notif[1]['tooltip'];
|
this._multi_calendar._reserv_tooltips[reserv['id']] = notif[1]['tooltip'];
|
||||||
nreservs.push(nreserv);
|
nreservs.push(nreserv);
|
||||||
}
|
}
|
||||||
need_update_counters = true;
|
need_update_counters = true;
|
||||||
@@ -761,13 +734,13 @@ var PMSCalendarController = AbstractController.extend({
|
|||||||
|
|
||||||
_generate_reservation_tooltip_dict: function(tp) {
|
_generate_reservation_tooltip_dict: function(tp) {
|
||||||
return {
|
return {
|
||||||
'name': tp[0],
|
'name': tp['name'],
|
||||||
'phone': tp[1],
|
'phone': tp['phone'],
|
||||||
'arrival_hour': HotelCalendar.toMomentUTC(tp[2], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT).local().format('HH:mm'),
|
'arrival_hour': HotelCalendar.toMomentUTC(tp['checkin'], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT).local().format('HH:mm'),
|
||||||
'num_split': tp[3],
|
'num_split': tp['num_split'],
|
||||||
'amount_total': Number(tp[4]).toLocaleString(),
|
'amount_total': Number(tp['amount_total']).toLocaleString(),
|
||||||
'reservation_type': tp[5],
|
'reservation_type': tp['type'],
|
||||||
'out_service_description': tp[6]
|
'out_service_description': tp['out_service_description']
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ odoo.define('hotel_calendar.MultiCalendar', function(require) {
|
|||||||
|
|
||||||
merge_days_tooltips: function(new_tooltips) {
|
merge_days_tooltips: function(new_tooltips) {
|
||||||
for (var nt of new_tooltips) {
|
for (var nt of new_tooltips) {
|
||||||
var fnt = _.find(this._days_tooltips, function(item) { return item[0] === nt[0]});
|
var fnt = _.find(this._days_tooltips, function(item) { return item['id'] === nt['id']});
|
||||||
if (fnt) {
|
if (fnt) {
|
||||||
fnt = nt;
|
fnt = nt;
|
||||||
} else {
|
} else {
|
||||||
@@ -347,7 +347,7 @@ odoo.define('hotel_calendar.MultiCalendar', function(require) {
|
|||||||
var $elm = $(elm);
|
var $elm = $(elm);
|
||||||
var cdate = HotelCalendar.toMoment($elm.data('hcalDate'), HotelConstants.L10N_DATE_MOMENT_FORMAT);
|
var cdate = HotelCalendar.toMoment($elm.data('hcalDate'), HotelConstants.L10N_DATE_MOMENT_FORMAT);
|
||||||
var data = _.filter(self._days_tooltips, function(item) {
|
var data = _.filter(self._days_tooltips, function(item) {
|
||||||
var ndate = HotelCalendar.toMoment(item[2], HotelConstants.ODOO_DATE_MOMENT_FORMAT);
|
var ndate = HotelCalendar.toMoment(item['date'], HotelConstants.ODOO_DATE_MOMENT_FORMAT);
|
||||||
return ndate.isSame(cdate, 'd');
|
return ndate.isSame(cdate, 'd');
|
||||||
});
|
});
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
@@ -360,9 +360,9 @@ odoo.define('hotel_calendar.MultiCalendar', function(require) {
|
|||||||
'date': $this.data('hcalDate'),
|
'date': $this.data('hcalDate'),
|
||||||
'events': _.map(data, function(item){
|
'events': _.map(data, function(item){
|
||||||
return {
|
return {
|
||||||
'name': item[1],
|
'name': item['name'],
|
||||||
'date': item[2],
|
'date': item['date'],
|
||||||
'location': item[3]
|
'location': item['location']
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -313,7 +313,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.hcal-reservation-splitted {
|
.hcal-reservation-splitted {
|
||||||
border-width: 1px 6px;
|
border-width: 0 6px;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,14 +26,6 @@ class BusHotelCalendar(models.TransientModel):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _generate_reservation_notif(self, vals):
|
|
||||||
json = super(BusHotelCalendar, self)._generate_reservation_notif(vals)
|
|
||||||
json['reservation'].update({
|
|
||||||
'external_id': vals['external_id'],
|
|
||||||
})
|
|
||||||
return json
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _generate_availability_notification(self, vals):
|
def _generate_availability_notification(self, vals):
|
||||||
date_dt = datetime.strptime(vals['date'], DEFAULT_SERVER_DATE_FORMAT)
|
date_dt = datetime.strptime(vals['date'], DEFAULT_SERVER_DATE_FORMAT)
|
||||||
|
|||||||
@@ -1,106 +1,35 @@
|
|||||||
# 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
|
||||||
from datetime import datetime, timedelta
|
from odoo import models, api
|
||||||
from odoo import models, fields, api, _
|
|
||||||
from odoo.tools import (
|
|
||||||
DEFAULT_SERVER_DATE_FORMAT,
|
|
||||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class HotelReservation(models.Model):
|
class HotelReservation(models.Model):
|
||||||
_inherit = "hotel.reservation"
|
_inherit = "hotel.reservation"
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _generate_reservation_notif(self, action, ntype, title,
|
|
||||||
id, reserv_id, partner_name,
|
|
||||||
adults, children, checkin, checkout,
|
|
||||||
folio_id, color, color_text, splitted,
|
|
||||||
parent_reservation, room_name,
|
|
||||||
partner_phone, state, fix_days):
|
|
||||||
vals = super(HotelReservation, self)._generate_reservation_notif(
|
|
||||||
action, ntype, title, id,
|
|
||||||
reserv_id, partner_name, adults,
|
|
||||||
children, checkin, checkout,
|
|
||||||
folio_id, color, color_text, splitted, parent_reservation,
|
|
||||||
room_name, partner_phone, state, fix_days)
|
|
||||||
reserv = self.env['hotel.reservation'].browse(vals['reserv_id'])
|
|
||||||
vals['reservation'].update({
|
|
||||||
'fix_days': (any(reserv.channel_bind_ids) and
|
|
||||||
reserv.channel_bind_ids[0].external_id) or fix_days,
|
|
||||||
'ota_id': (any(reserv.channel_bind_ids) and
|
|
||||||
reserv.channel_bind_ids[0].ota_id and
|
|
||||||
reserv.channel_bind_ids[0].ota_id.name),
|
|
||||||
})
|
|
||||||
return vals
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _hcalendar_reservation_data(self, reservations):
|
def _hcalendar_reservation_data(self, reservations):
|
||||||
vals = super(HotelReservation, self)._hcalendar_reservation_data(reservations)
|
vals = super(HotelReservation, self)._hcalendar_reservation_data(reservations)
|
||||||
hotel_reservation_obj = self.env['hotel.reservation']
|
hotel_reservation_obj = self.env['hotel.reservation']
|
||||||
json_reservations = []
|
|
||||||
for v_rval in vals[0]:
|
for v_rval in vals[0]:
|
||||||
reserv = hotel_reservation_obj.browse(v_rval[1])
|
reserv = hotel_reservation_obj.browse(v_rval['id'])
|
||||||
json_reservations.append((
|
v_rval.update({
|
||||||
reserv.room_id.id,
|
'fix_days': reserv.splitted or reserv.is_from_ota,
|
||||||
reserv.id,
|
})
|
||||||
reserv.folio_id.partner_id.name,
|
|
||||||
reserv.adults,
|
|
||||||
reserv.children,
|
|
||||||
reserv.checkin,
|
|
||||||
reserv.checkout,
|
|
||||||
reserv.folio_id.id,
|
|
||||||
reserv.reserve_color,
|
|
||||||
reserv.reserve_color_text,
|
|
||||||
reserv.splitted,
|
|
||||||
reserv.parent_reservation.id,
|
|
||||||
# Read-Only
|
|
||||||
False,
|
|
||||||
# Fix Days
|
|
||||||
(any(reserv.channel_bind_ids) and
|
|
||||||
reserv.channel_bind_ids[0].external_id) or reserv.splitted,
|
|
||||||
# Fix Rooms
|
|
||||||
False,
|
|
||||||
reserv.overbooking))
|
|
||||||
# Update tooltips
|
# Update tooltips
|
||||||
if any(reserv.channel_bind_ids):
|
vals[1][reserv.id].update({
|
||||||
vals[1][reserv.id].append(reserv.channel_bind_ids[0].ota_id.name)
|
'ota_name': reserv.channel_bind_ids[0].ota_id.name if any(reserv.channel_bind_ids) else False
|
||||||
else:
|
})
|
||||||
vals[1][reserv.id].append(False)
|
return vals
|
||||||
return (json_reservations, vals[1])
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def send_bus_notification(self, naction, ntype, ntitle=''):
|
def generate_bus_values(self, naction, ntype, ntitle=''):
|
||||||
hotel_cal_obj = self.env['bus.hotel.calendar']
|
vals = super(HotelReservation, self).generate_bus_values(naction, ntype, ntitle)
|
||||||
for record in self:
|
vals.update({
|
||||||
hotel_cal_obj.send_reservation_notification({
|
'fix_days': self.splitted or self.is_from_ota,
|
||||||
'action': naction,
|
})
|
||||||
'type': ntype,
|
return vals
|
||||||
'title': ntitle,
|
|
||||||
'room_id': record.room_id.id,
|
|
||||||
'reserv_id': record.id,
|
|
||||||
'partner_name': record.partner_id.name,
|
|
||||||
'adults': record.adults,
|
|
||||||
'children': record.children,
|
|
||||||
'checkin': record.checkin,
|
|
||||||
'checkout': record.checkout,
|
|
||||||
'folio_id': record.folio_id.id,
|
|
||||||
'reserve_color': record.reserve_color,
|
|
||||||
'reserve_color_text': record.reserve_color_text,
|
|
||||||
'splitted': record.splitted,
|
|
||||||
'parent_reservation': record.parent_reservation and
|
|
||||||
record.parent_reservation.id or 0,
|
|
||||||
'room_name': record.room_id.name,
|
|
||||||
'partner_phone': record.partner_id.mobile or
|
|
||||||
record.partner_id.phone or _('Undefined'),
|
|
||||||
'state': record.state,
|
|
||||||
'fix_days': record.splitted or record.is_from_ota,
|
|
||||||
'overbooking': record.overbooking,
|
|
||||||
'price': record.folio_id.amount_total,
|
|
||||||
'external_id': (any(record.channel_bind_ids) and
|
|
||||||
record.channel_bind_ids[0].external_id),
|
|
||||||
})
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ var PMSHotelCalendarControllerChannelConnector = PMSCalendarController.include({
|
|||||||
this._sounds[SoundID].play();
|
this._sounds[SoundID].play();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_generate_reservation_tooltip_dict: function(tp) {
|
||||||
|
var qdict = this._super(tp);
|
||||||
|
qdict['ota_name'] = tp['ota_name'];
|
||||||
|
return qdict;
|
||||||
|
},
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// Handlers
|
// Handlers
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -38,12 +38,6 @@ odoo.define('hotel_calendar_channel_connector.PMSHotelCalendarRendererChannelCon
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_generate_reservation_tooltip_dict: function(tp) {
|
|
||||||
var qdict = this._super(tp);
|
|
||||||
qdict['channel_name'] = tp[5];
|
|
||||||
return qdict;
|
|
||||||
},
|
|
||||||
|
|
||||||
_generate_bookings_domain: function(tsearch) {
|
_generate_bookings_domain: function(tsearch) {
|
||||||
var domain = this._super(tsearch);
|
var domain = this._super(tsearch);
|
||||||
domain.splice(0, 0, '|');
|
domain.splice(0, 0, '|');
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<t t-extend="HotelCalendar.TooltipReservation">
|
<t t-extend="HotelCalendar.TooltipReservation">
|
||||||
<t t-jquery="ul.oe_tooltip_technical li:last-child" t-operation="after">
|
<t t-jquery="ul.oe_tooltip_technical li:last-child" t-operation="after">
|
||||||
<li t-if="channel_name"><b>Channel:</b> <t t-esc="channel_name"/></li>
|
<li t-if="ota_name"><b>OTA:</b> <t t-esc="ota_name"/></li>
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
|
|
||||||
|
|||||||
@@ -180,21 +180,20 @@ class HotelReservation(models.Model):
|
|||||||
vals.update({'to_read': True})
|
vals.update({'to_read': True})
|
||||||
return super(HotelReservation, self).create(vals)
|
return super(HotelReservation, self).create(vals)
|
||||||
|
|
||||||
# @api.multi
|
@api.multi
|
||||||
# def generate_copy_values(self, checkin=False, checkout=False):
|
def generate_copy_values(self, checkin=False, checkout=False):
|
||||||
# self.ensure_one()
|
self.ensure_one()
|
||||||
# res = super().generate_copy_values(checkin=checkin, checkout=checkout)
|
res = super().generate_copy_values(checkin=checkin, checkout=checkout)
|
||||||
# res.update({
|
commands = []
|
||||||
# 'channel_reservation_id': self.channel_reservation_id,
|
for bind_id in self.channel_bind_ids.ids:
|
||||||
# 'ota_id': self.ota_id and self.ota_id.id or False,
|
commands.append((4, bind_id, False))
|
||||||
# 'ota_reservation_code': self.ota_reservation_code,
|
res.update({
|
||||||
# 'is_from_ota': self.is_from_ota,
|
'channel_bind_ids': commands,
|
||||||
# 'to_read': self.to_read,
|
'customer_notes': self.customer_notes,
|
||||||
# 'wstatus': self.wstatus,
|
'is_from_ota': self.is_from_ota,
|
||||||
# 'wstatus_reason': self.wstatus_reason,
|
'to_read': self.to_read,
|
||||||
# 'customer_notes': self.customer_notes,
|
})
|
||||||
# })
|
return res
|
||||||
# return res
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_reservation_checkout(self):
|
def action_reservation_checkout(self):
|
||||||
@@ -208,8 +207,8 @@ class HotelReservation(models.Model):
|
|||||||
|
|
||||||
reserv_obj = self.env['hotel.reservation']
|
reserv_obj = self.env['hotel.reservation']
|
||||||
for reserv in json_reservs:
|
for reserv in json_reservs:
|
||||||
reservation = reserv_obj.browse(reserv[1])
|
reservation = reserv_obj.browse(reserv['id'])
|
||||||
reserv[13] = reservation.splitted or reservation.is_from_ota
|
reserv['fix_days'] = reservation.splitted or reservation.is_from_ota
|
||||||
|
|
||||||
return (json_reservs, json_tooltips)
|
return (json_reservs, json_tooltips)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user