mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] availability in cancelled modifications
This commit is contained in:
@@ -252,6 +252,18 @@ class HotelReservationImporter(Component):
|
|||||||
|
|
||||||
return (checkin_utc_dt, checkout_utc_dt)
|
return (checkin_utc_dt, checkout_utc_dt)
|
||||||
|
|
||||||
|
def _force_update_availability_wubook(self, binding):
|
||||||
|
# WuBook always add +1 in the channel manager for cancelled reservation
|
||||||
|
# However, the quota in Odoo has preference in the availability
|
||||||
|
cancelled_dates = binding.reservation_line_ids.mapped('date')
|
||||||
|
channel_availability = self.env['channel.hotel.room.type.availability'].search([
|
||||||
|
('backend_id', '=', binding.backend_id.id),
|
||||||
|
('date', 'in', cancelled_dates)
|
||||||
|
])
|
||||||
|
channel_availability.write({'channel_pushed': False})
|
||||||
|
# Force an update with the correct availability
|
||||||
|
channel_availability.push_availability(binding.backend_id)
|
||||||
|
|
||||||
def _update_reservation_binding(self, binding, book):
|
def _update_reservation_binding(self, binding, book):
|
||||||
is_cancellation = book['status'] in WUBOOK_STATUS_BAD
|
is_cancellation = book['status'] in WUBOOK_STATUS_BAD
|
||||||
binding.with_context({'connector_no_export': True}).write({
|
binding.with_context({'connector_no_export': True}).write({
|
||||||
@@ -270,16 +282,7 @@ class HotelReservationImporter(Component):
|
|||||||
binding.odoo_id.with_context({
|
binding.odoo_id.with_context({
|
||||||
'connector_no_export': True,
|
'connector_no_export': True,
|
||||||
'ota_limits': False}).action_cancel()
|
'ota_limits': False}).action_cancel()
|
||||||
# WuBook always add +1 in the channel manager for cancelled reservation
|
self._force_update_availability_wubook(binding)
|
||||||
# However, the quota in Odoo has preference in the availability
|
|
||||||
cancelled_dates = binding.reservation_line_ids.mapped('date')
|
|
||||||
channel_availability = self.env['channel.hotel.room.type.availability'].search([
|
|
||||||
('backend_id', '=', binding.backend_id.id),
|
|
||||||
('date', 'in', cancelled_dates)
|
|
||||||
])
|
|
||||||
channel_availability.write({'channel_pushed': False})
|
|
||||||
# Force an update with the correct availability
|
|
||||||
channel_availability.push_availability(binding.backend_id)
|
|
||||||
elif binding.state == 'cancelled':
|
elif binding.state == 'cancelled':
|
||||||
binding.with_context({
|
binding.with_context({
|
||||||
'connector_no_export': True,
|
'connector_no_export': True,
|
||||||
@@ -336,6 +339,8 @@ class HotelReservationImporter(Component):
|
|||||||
reservations -= reservation
|
reservations -= reservation
|
||||||
else:
|
else:
|
||||||
new_books.append(broom)
|
new_books.append(broom)
|
||||||
|
# Review quota if new reservation is a modification not recognized in this method
|
||||||
|
# because quota is __always__ decreased when creating reservation, even in the overlapped days
|
||||||
return new_books, reservations
|
return new_books, reservations
|
||||||
|
|
||||||
|
|
||||||
@@ -410,6 +415,7 @@ class HotelReservationImporter(Component):
|
|||||||
'connector_no_export': True,
|
'connector_no_export': True,
|
||||||
'ota_limits': False,
|
'ota_limits': False,
|
||||||
'no_penalty': True}).action_cancel()
|
'no_penalty': True}).action_cancel()
|
||||||
|
self._force_update_availability_wubook(res.channel_bind_ids[0])
|
||||||
if len(new_books) == 0:
|
if len(new_books) == 0:
|
||||||
processed_rids.append(rcode)
|
processed_rids.append(rcode)
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user