diff --git a/hotel_channel_connector/models/hotel_reservation/importer.py b/hotel_channel_connector/models/hotel_reservation/importer.py index 6c61f40d1..e171ff33d 100644 --- a/hotel_channel_connector/models/hotel_reservation/importer.py +++ b/hotel_channel_connector/models/hotel_reservation/importer.py @@ -108,6 +108,7 @@ class HotelReservationImporter(Component): tprice += room_day_price # Get OTA ota_id = self.env['channel.ota.info'].search([ + ('backend_id', '=', self.backend_record.id), ('ota_id', '=', str(book['id_channel'])), ], limit=1) @@ -248,21 +249,25 @@ class HotelReservationImporter(Component): # Search Folio. If exists. folio_id = False if crcode != 'undefined': - reserv_folio = channel_reserv_obj.search([ - ('ota_reservation_id', '=', crcode) + reserv_bind = channel_reserv_obj.search([ + ('ota_reservation_id', '=', crcode), ], limit=1) - if reserv_folio: - folio_id = reserv_folio.odoo_id.folio_id + if reserv_bind: + folio_id = reserv_bind.folio_id else: - reserv_folio = channel_reserv_obj.search([ - ('external_id', '=', rcode) + reserv_bind = channel_reserv_obj.search([ + ('backend_id', '=', self.backend_record.id), + ('external_id', '=', rcode), ], limit=1) - if reserv_folio: - folio_id = reserv_folio.odoo_id.folio_id + if reserv_bind: + folio_id = reserv_bind.folio_id # Need update reservations? reservs_processed = False - reservs_binds = channel_reserv_obj.search([('external_id', '=', rcode)]) + reservs_binds = channel_reserv_obj.search([ + ('backend_id', '=', self.backend_record.id), + ('external_id', '=', rcode), + ]) for reserv_bind in reservs_binds: self._update_reservation_binding(reserv_bind, book) reservs_processed = True @@ -286,6 +291,7 @@ class HotelReservationImporter(Component): # Iterate booked rooms for broom in book['booked_rooms']: room_type_bind = channel_room_type_obj.search([ + ('backend_id', '=', self.backend_record.id), ('external_id', '=', broom['room_id']) ], limit=1) if not room_type_bind: diff --git a/hotel_channel_connector/models/hotel_room_type/importer.py b/hotel_channel_connector/models/hotel_room_type/importer.py index 60d34713f..a7d797957 100644 --- a/hotel_channel_connector/models/hotel_room_type/importer.py +++ b/hotel_channel_connector/models/hotel_room_type/importer.py @@ -38,7 +38,8 @@ class HotelRoomTypeImporter(Component): for room in results: map_record = room_mapper.map_record(room) room_bind = channel_room_type_obj.search([ - ('external_id', '=', room['id']) + ('backend_id', '=', self.backend_record.id), + ('external_id', '=', room['id']), ], limit=1) if room_bind: room_bind.with_context({'connector_no_export':True}).write(map_record.values()) diff --git a/hotel_channel_connector/models/hotel_room_type_restriction/importer.py b/hotel_channel_connector/models/hotel_room_type_restriction/importer.py index f7bee2702..0af297f94 100644 --- a/hotel_channel_connector/models/hotel_room_type_restriction/importer.py +++ b/hotel_channel_connector/models/hotel_room_type_restriction/importer.py @@ -34,7 +34,8 @@ class HotelRoomTypeRestrictionImporter(Component): for plan in results: plan_record = restriction_mapper.map_record(plan) plan_bind = channel_restriction_obj.search([ - ('external_id', '=', str(plan['id'])) + ('backend_id', '=', self.backend_record.id), + ('external_id', '=', str(plan['id'])), ], limit=1) if not plan_bind: channel_restriction_obj.with_context({ diff --git a/hotel_channel_connector/models/hotel_room_type_restriction_item/importer.py b/hotel_channel_connector/models/hotel_room_type_restriction_item/importer.py index f151042a2..d6a9897bf 100644 --- a/hotel_channel_connector/models/hotel_room_type_restriction_item/importer.py +++ b/hotel_channel_connector/models/hotel_room_type_restriction_item/importer.py @@ -32,12 +32,14 @@ class HotelRoomTypeRestrictionImporter(Component): _logger.info(plan_restrictions) for k_rpid, v_rpid in plan_restrictions.items(): channel_restriction_id = channel_reserv_restriction_obj.search([ - ('external_id', '=', k_rpid) + ('backend_id', '=', self.backend_record.id), + ('external_id', '=', k_rpid), ], limit=1) if channel_restriction_id: for k_rid, v_rid in v_rpid.items(): channel_room_type = channel_hotel_room_type_obj.search([ - ('external_id', '=', k_rid) + ('backend_id', '=', self.backend_record.id), + ('external_id', '=', k_rid), ], limit=1) if channel_room_type: for item in v_rid: diff --git a/hotel_channel_connector/models/product_pricelist/importer.py b/hotel_channel_connector/models/product_pricelist/importer.py index 54e5e7ff0..1fce0106b 100644 --- a/hotel_channel_connector/models/product_pricelist/importer.py +++ b/hotel_channel_connector/models/product_pricelist/importer.py @@ -38,7 +38,8 @@ class ProductPricelistImporter(Component): continue # FIXME: Ignore Virtual Plans plan_record = pricelist_mapper.map_record(plan) plan_bind = channel_product_listprice_obj.search([ - ('external_id', '=', str(plan['id'])) + ('backend_id', '=', self.backend_record.id), + ('external_id', '=', str(plan['id'])), ], limit=1) if not plan_bind: channel_product_listprice_obj.with_context({ diff --git a/hotel_channel_connector/models/product_pricelist_item/importer.py b/hotel_channel_connector/models/product_pricelist_item/importer.py index 52b13d9a5..9a5f188b2 100644 --- a/hotel_channel_connector/models/product_pricelist_item/importer.py +++ b/hotel_channel_connector/models/product_pricelist_item/importer.py @@ -26,7 +26,8 @@ class ProductPricelistItemImporter(Component): _logger.info(plan_prices) channel_hotel_room_type_obj = self.env['channel.hotel.room.type'] pricelist_bind = self.env['channel.product.pricelist'].search([ - ('external_id', '=', channel_plan_id) + ('backend_id', '=', self.backend_record.id), + ('external_id', '=', channel_plan_id), ], limit=1) pricelist_item_mapper = self.component( usage='import.mapper', @@ -40,7 +41,8 @@ class ProductPricelistItemImporter(Component): ndate_dt = dfrom_dt + timedelta(days=i) for k_rid, v_rid in plan_prices.items(): channel_room_type = channel_hotel_room_type_obj.search([ - ('external_id', '=', k_rid) + ('backend_id', '=', self.backend_record.id), + ('external_id', '=', k_rid), ], limit=1) if channel_room_type: ndate_str = ndate_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)