mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] notify calendar with channel connector information
This commit is contained in:
@@ -1,14 +1,35 @@
|
||||
# Copyright 2018-2019 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from odoo import models, api
|
||||
from odoo.addons.hotel_calendar.controllers.bus import HOTEL_BUS_CHANNEL_ID
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BusHotelCalendar(models.TransientModel):
|
||||
_inherit = 'bus.hotel.calendar'
|
||||
|
||||
@api.model
|
||||
def _generate_reservation_notif(self, vals):
|
||||
notif = super(BusHotelCalendar, self)._generate_reservation_notif(vals)
|
||||
reserv = self.env['hotel.reservation'].browse(vals['reserv_id'])
|
||||
if any(reserv.channel_bind_ids):
|
||||
notif['tooltip'].update({
|
||||
'ota_name': reserv.channel_bind_ids[0].ota_id.name,
|
||||
'ota_reservation_id': reserv.channel_bind_ids[0].ota_reservation_id,
|
||||
'external_id': reserv.channel_bind_ids[0].external_id,
|
||||
})
|
||||
elif reserv.splitted and reserv.parent_reservation.channel_bind_ids:
|
||||
# chunks in splitted reservation has not channel_bind_ids
|
||||
notif['tooltip'].update({
|
||||
'ota_name': reserv.parent_reservation.channel_bind_ids[0].ota_id.name,
|
||||
'ota_reservation_id': reserv.parent_reservation.channel_bind_ids[0].ota_reservation_id,
|
||||
'external_id': reserv.parent_reservation.channel_bind_ids[0].external_id,
|
||||
})
|
||||
return notif
|
||||
|
||||
@api.model
|
||||
def _generate_availability_notification(self, vals):
|
||||
date_dt = datetime.strptime(vals['date'], DEFAULT_SERVER_DATE_FORMAT)
|
||||
|
||||
@@ -25,14 +25,29 @@ class HotelReservation(models.Model):
|
||||
'ota_reservation_id': reserv.channel_bind_ids[0].ota_reservation_id,
|
||||
'external_id': reserv.channel_bind_ids[0].external_id,
|
||||
})
|
||||
elif reserv.splitted and reserv.parent_reservation.channel_bind_ids:
|
||||
# chunks in splitted reservation has not channel_bind_ids
|
||||
vals[1][reserv.id].update({
|
||||
'ota_name': reserv.parent_reservation.channel_bind_ids[0].ota_id.name,
|
||||
'ota_reservation_id': reserv.parent_reservation.channel_bind_ids[0].ota_reservation_id,
|
||||
'external_id': reserv.parent_reservation.channel_bind_ids[0].external_id,
|
||||
})
|
||||
# REVIEW: What happens if the reservation is splitted and no parent with channel_bind_ids ¿?
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
def generate_bus_values(self, naction, ntype, ntitle=''):
|
||||
self.ensure_one()
|
||||
vals = super(HotelReservation, self).generate_bus_values(naction, ntype, ntitle)
|
||||
vals.update({
|
||||
'fix_days': self.splitted or self.is_from_ota,
|
||||
})
|
||||
if any(self.channel_bind_ids):
|
||||
vals.update({
|
||||
'ota_name': self.channel_bind_ids[0].ota_id.name,
|
||||
'ota_reservation_id': self.channel_bind_ids[0].ota_reservation_id,
|
||||
'external_id': self.channel_bind_ids[0].external_id,
|
||||
})
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
|
||||
Reference in New Issue
Block a user