From db5435c8969754c3e4c7b066ba93a5d90777acc7 Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 30 May 2019 17:06:37 +0200 Subject: [PATCH] [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: