From 0f264152da5e070f42716e4b6b6552b452653466 Mon Sep 17 00:00:00 2001 From: Pablo Date: Fri, 19 Apr 2019 18:06:23 +0200 Subject: [PATCH] [FIX] WuBook availability +1 for cancelled reservation --- .../models/hotel_reservation/importer.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py index 04f408309..7c530d136 100644 --- a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py +++ b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py @@ -243,6 +243,16 @@ class HotelReservationImporter(Component): if is_cancellation: binding.odoo_id.with_context({ 'connector_no_export': True}).action_cancel() + # 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) elif binding.state == 'cancelled': binding.with_context({ 'connector_no_export': True,