From 6f7283c46de92f40d8c35e544725f546c74f6b95 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Thu, 18 Apr 2019 17:48:32 +0200 Subject: [PATCH] [FIX] is_from_ota compute --- .../models/hotel_reservation/common.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hotel_channel_connector/models/hotel_reservation/common.py b/hotel_channel_connector/models/hotel_reservation/common.py index 2fa037b52..36d25d684 100644 --- a/hotel_channel_connector/models/hotel_reservation/common.py +++ b/hotel_channel_connector/models/hotel_reservation/common.py @@ -46,11 +46,6 @@ class ChannelHotelReservation(models.Model): 'A binding already exists with the same Channel ID.'), ] - @api.depends('channel_reservation_id', 'ota_id') - def _is_from_ota(self): - for record in self: - record.is_from_ota = (record.external_id and record.ota_id) - @job(default_channel='root.channel') @api.model def refresh_availability(self, checkin, checkout, backend_id, room_id): @@ -152,13 +147,20 @@ class HotelReservation(models.Model): # origin_sale = fields.Char('Origin', compute=_get_origin_sale, # store=True) is_from_ota = fields.Boolean('Is From OTA', - readonly=True) + compute='_is_from_ota', + store=True) able_to_modify_channel = fields.Boolean(compute=_set_access_for_channel_fields, string='Is user able to modify channel fields?') customer_notes = fields.Text(related='folio_id.customer_notes') unconfirmed_channel_price = fields.Boolean(related='folio_id.unconfirmed_channel_price') + @api.depends('channel_bind_ids.external_id', 'channel_bind_ids.ota_id') + def _is_from_ota(self): + for record in self: + record.is_from_ota = bool(any(bind.ota_reservation_id + for bind in record.channel_bind_ids)) + @api.onchange('checkin', 'checkout') def onchange_dates(self): if not self.is_from_ota: