[TMP][FIX] reduce updates to crontab actions to prevent anti-flood policies

This commit is contained in:
Pablo
2019-05-30 17:06:37 +02:00
parent d18a760157
commit db5435c896
2 changed files with 6 additions and 4 deletions

View File

@@ -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()

View File

@@ -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: