From 4d025c1134e31aa2c9aebb1f2353e192bddb4e8c Mon Sep 17 00:00:00 2001 From: Pablo Date: Mon, 27 May 2019 18:08:32 +0200 Subject: [PATCH 1/3] [UPD] Do not search for existing partners by email --- .../models/hotel_reservation/importer.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py index 6bc1975a2..cc6eb5173 100644 --- a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py +++ b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py @@ -350,15 +350,8 @@ class HotelReservationImporter(Component): processed_rids.append(rcode) continue - # Search Customer - customer_mail = book.get('customer_mail', False) - partner_id = False - if customer_mail: - partner_id = res_partner_obj.search([ - ('email', '=', customer_mail) - ], limit=1) - if not partner_id: - partner_id = res_partner_obj.create(self._generate_partner_vals(book)) + # Create new Customer + partner_id = res_partner_obj.create(self._generate_partner_vals(book)) reservations = [] used_rooms = [] From d18a760157251ed23c26e400002d4e8376aed21d Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 30 May 2019 16:41:23 +0200 Subject: [PATCH 2/3] [TMP][FIX] push all availability --- .../models/hotel_room_type_availability/exporter.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py b/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py index 220a8e44f..9ca93948f 100644 --- a/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py +++ b/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py @@ -17,7 +17,7 @@ class HotelRoomTypeAvailabilityExporter(Component): channel_hotel_room_type_obj = self.env['channel.hotel.room.type'] channel_room_type_avail_ids = self.env['channel.hotel.room.type.availability'].search([ ('backend_id', '=', self.backend_record.id), - ('channel_pushed', '=', False), + # ('channel_pushed', '=', False), ('date', '>=', fields.Date.today()) ]) room_types = channel_room_type_avail_ids.mapped('room_type_id') @@ -44,6 +44,17 @@ class HotelRoomTypeAvailabilityExporter(Component): _logger.info(avails) if any(avails): try: + # For functions updating room values (like availability, prices, restrictions and so on), + # for example update_avail(), there is a maximum number of updatable days (for __each room__) + # depending on the time window. + # Number of updated days Time window (seconds) + # 1460 1 + # 4380 180 + # 13140 3600 + # 25550 43200 + # 29200 86400 + # 32850 172800 + # 36500 259200 self.backend_adapter.update_availability(avails) except ChannelConnectorError as err: self.create_issue( From db5435c8969754c3e4c7b066ba93a5d90777acc7 Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 30 May 2019 17:06:37 +0200 Subject: [PATCH 3/3] [TMP][FIX] reduce updates to crontab actions to prevent anti-flood policies --- hotel_channel_connector/models/channel_backend/common.py | 2 +- .../models/hotel_room_type_availability/exporter.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hotel_channel_connector/models/channel_backend/common.py b/hotel_channel_connector/models/channel_backend/common.py index bad5d6132..2434e623d 100644 --- a/hotel_channel_connector/models/channel_backend/common.py +++ b/hotel_channel_connector/models/channel_backend/common.py @@ -244,7 +244,7 @@ class ChannelBackend(models.Model): @api.model def cron_push_changes(self): backends = self.env[self._name].search([]) - backends.push_availability() + backends.with_context({'force_update': True}).push_availability() backends.push_restriction() backends.push_pricelist() diff --git a/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py b/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py index 9ca93948f..158176681 100644 --- a/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py +++ b/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py @@ -15,11 +15,13 @@ class HotelRoomTypeAvailabilityExporter(Component): def push_availability(self): channel_hotel_room_type_obj = self.env['channel.hotel.room.type'] - channel_room_type_avail_ids = self.env['channel.hotel.room.type.availability'].search([ + search_domain = [ ('backend_id', '=', self.backend_record.id), - # ('channel_pushed', '=', False), ('date', '>=', fields.Date.today()) - ]) + ] + if not self.env['channel.hotel.room.type.availability']._context.get('force_update', False): + search_domain.append(('channel_pushed', '=', False)) + channel_room_type_avail_ids = self.env['channel.hotel.room.type.availability'].search(search_domain) room_types = channel_room_type_avail_ids.mapped('room_type_id') avails = [] for room_type in room_types: