Merge branch '11.0' of https://github.com/hootel/hootel into 11.0

This commit is contained in:
Dario Lodeiros
2019-05-31 10:51:16 +02:00
3 changed files with 19 additions and 13 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

@@ -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 = []

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:
@@ -44,6 +46,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(