From 46e488ed7c1bebccd45975cc2b87b00e6af968f1 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Thu, 7 Feb 2019 12:15:46 +0100 Subject: [PATCH] [WIP] Wubook revision --- .../hotel_room_type_availability/common.py | 2 +- .../models/hotel_reservation/importer.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hotel_channel_connector/models/hotel_room_type_availability/common.py b/hotel_channel_connector/models/hotel_room_type_availability/common.py index cdcd657f3..6bda5e607 100644 --- a/hotel_channel_connector/models/hotel_room_type_availability/common.py +++ b/hotel_channel_connector/models/hotel_room_type_availability/common.py @@ -68,7 +68,7 @@ class ChannelHotelRoomTypeAvailability(models.Model): _inherits = {'hotel.room.type.availability': 'odoo_id'} _description = 'Channel Availability' - avail = fields.Integer("Avail", default=0, readonly=True) + # avail = fields.Integer("Avail", default=0, readonly=True) odoo_id = fields.Many2one(comodel_name='hotel.room.type.availability', string='Pricelist', required=True, diff --git a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py index 3e62d74c6..f05b1bf5f 100644 --- a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py +++ b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py @@ -109,9 +109,15 @@ class HotelReservationImporter(Component): ('backend_id', '=', self.backend_record.id), ('ota_id', '=', str(book['id_channel'])), ], limit=1) - - vals = { + binding_vals = { 'backend_id': self.backend_record.id, + 'external_id': rcode, + 'ota_id': ota_id and ota_id.id, + 'ota_reservation_id': crcode, + 'channel_raw_data': json.dumps(book), + 'channel_modified': book['was_modified'], + } + vals = { 'checkin': checkin_str, 'checkout': checkout_str, 'adults': persons, @@ -119,19 +125,14 @@ class HotelReservationImporter(Component): 'reservation_lines': reservation_lines, 'price_unit': tprice, 'to_assign': True, - 'external_id': rcode, - 'ota_id': ota_id and ota_id.id, - 'ota_reservation_id': crcode, - 'channel_status': str(book['status']), 'to_read': True, 'state': is_cancellation and 'cancelled' or 'draft', 'room_type_id': room_type_bind.odoo_id.id, 'splitted': split_booking, - 'channel_raw_data': json.dumps(book), - 'channel_modified': book['was_modified'], - 'product_id': room_type_bind and room_type_bind.product_id.id, 'name': room_type_bind and room_type_bind.name, + 'channel_bind_ids': [(0, False, binding_vals)] } + return vals @api.model