mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Refactor (#58)
This commit is contained in:
@@ -11,9 +11,8 @@ class HotelCalendarManagement(models.TransientModel):
|
|||||||
vals = super(HotelCalendarManagement, self)._get_availability_values(
|
vals = super(HotelCalendarManagement, self)._get_availability_values(
|
||||||
avail, room_type)
|
avail, room_type)
|
||||||
vals.update({
|
vals.update({
|
||||||
'wmax_avail': vals['avail'],
|
'channel_max_avail': vals['avail'],
|
||||||
'no_ota': vals['no_ota'],
|
'no_ota': avail['no_ota'],
|
||||||
'booked': vals['booked'],
|
|
||||||
})
|
})
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
|
|||||||
@@ -27,15 +27,17 @@ class HotelReservation(models.Model):
|
|||||||
room_name, partner_phone, state, fix_days)
|
room_name, partner_phone, state, fix_days)
|
||||||
reserv = self.env['hotel.reservation'].browse(vals['reserv_id'])
|
reserv = self.env['hotel.reservation'].browse(vals['reserv_id'])
|
||||||
vals['reservation'].update({
|
vals['reservation'].update({
|
||||||
'fix_days': (reserv.wrid and reserv.wrid != '') or fix_days,
|
'fix_days': (any(reserv.channel_bind_ids) and
|
||||||
'wchannel': (reserv.wchannel_id and reserv.wchannel_id.name),
|
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
|
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(
|
vals = super(HotelReservation, self)._hcalendar_reservation_data(reservations)
|
||||||
reservations)
|
|
||||||
hotel_reservation_obj = self.env['hotel.reservation']
|
hotel_reservation_obj = self.env['hotel.reservation']
|
||||||
json_reservations = []
|
json_reservations = []
|
||||||
for v_rval in vals[0]:
|
for v_rval in vals[0]:
|
||||||
@@ -56,12 +58,16 @@ class HotelReservation(models.Model):
|
|||||||
# Read-Only
|
# Read-Only
|
||||||
False,
|
False,
|
||||||
# Fix Days
|
# Fix Days
|
||||||
(reserv.wrid and reserv.wrid != '') or reserv.splitted,
|
(any(reserv.channel_bind_ids) and
|
||||||
|
reserv.channel_bind_ids[0].external_id) or reserv.splitted,
|
||||||
# Fix Rooms
|
# Fix Rooms
|
||||||
False,
|
False,
|
||||||
reserv.overbooking))
|
reserv.overbooking))
|
||||||
# Update tooltips
|
# Update tooltips
|
||||||
vals[1][reserv.id].append(reserv.wchannel_id.name)
|
if any(reserv.channel_bind_ids):
|
||||||
|
vals[1][reserv.id].append(reserv.channel_bind_ids[0].ota_id.name)
|
||||||
|
else:
|
||||||
|
vals[1][reserv.id].append(False)
|
||||||
return (json_reservations, vals[1])
|
return (json_reservations, vals[1])
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -92,7 +98,8 @@ class HotelReservation(models.Model):
|
|||||||
'fix_days': record.splitted or record.is_from_ota,
|
'fix_days': record.splitted or record.is_from_ota,
|
||||||
'overbooking': record.overbooking,
|
'overbooking': record.overbooking,
|
||||||
'price': record.folio_id.amount_total,
|
'price': record.folio_id.amount_total,
|
||||||
'wrid': record.wrid,
|
'external_id': (any(record.channel_bind_ids) and
|
||||||
|
record.channel_bind_ids[0].external_id),
|
||||||
})
|
})
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
|||||||
@@ -178,7 +178,8 @@ class HotelReservation(models.Model):
|
|||||||
def unlink(self):
|
def unlink(self):
|
||||||
vals = []
|
vals = []
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.wrid and not record.parent_reservation:
|
if any(record.channel_bind_ids) and record.channel_bind_ids[0].external_id \
|
||||||
|
and not record.parent_reservation:
|
||||||
raise UserError(_("You can't delete OTA's reservations"))
|
raise UserError(_("You can't delete OTA's reservations"))
|
||||||
vals.append({
|
vals.append({
|
||||||
'checkin': record.checkin,
|
'checkin': record.checkin,
|
||||||
|
|||||||
Reference in New Issue
Block a user