From df1be8420a9620e1a80de57323b68aee879bb5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Lodeiros?= Date: Sat, 2 Mar 2024 18:11:49 +0100 Subject: [PATCH] [ADD]pms_api_rest: sale_channel_service isOnLine search param --- pms_api_rest/datamodels/pms_sale_channel.py | 2 ++ pms_api_rest/models/pms_property.py | 23 ++++++++++--------- .../services/pms_sale_channel_service.py | 3 +++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pms_api_rest/datamodels/pms_sale_channel.py b/pms_api_rest/datamodels/pms_sale_channel.py index 730bb8037..10eee3d09 100644 --- a/pms_api_rest/datamodels/pms_sale_channel.py +++ b/pms_api_rest/datamodels/pms_sale_channel.py @@ -6,6 +6,7 @@ from odoo.addons.datamodel.core import Datamodel class PmsSaleChannelSearchParam(Datamodel): _name = "pms.sale.channel.search.param" pmsPropertyIds = fields.List(fields.Integer(), required=False) + IsOnLine = fields.Boolean(required=False, allow_none=True) class PmsSaleChannelInfo(Datamodel): @@ -14,3 +15,4 @@ class PmsSaleChannelInfo(Datamodel): name = fields.String(required=True, allow_none=False) channelType = fields.String(required=True, allow_none=True) iconUrl = fields.String(required=False, allow_none=True) + isOnLine = fields.Boolean(required=True, allow_none=False) diff --git a/pms_api_rest/models/pms_property.py b/pms_api_rest/models/pms_property.py index 31afd5e25..45d558330 100644 --- a/pms_api_rest/models/pms_property.py +++ b/pms_api_rest/models/pms_property.py @@ -121,7 +121,7 @@ class PmsProperty(models.Model): property_client_conf = self.env["ota.property.settings"].search( [ ("pms_property_id", "=", self.id), - ("agency_id", "=", client.id), + ("agency_id", "=", client.partner_id.id), ] ) plan_avail = property_client_conf.main_avail_plan_id @@ -301,7 +301,7 @@ class PmsProperty(models.Model): property_client_conf = self.env["ota.property.settings"].search( [ ("pms_property_id", "=", pms_property_id), - ("agency_id", "=", client.id), + ("agency_id", "=", client.partner_id.id), ] ) plan_avail = property_client_conf.main_avail_plan_id @@ -401,7 +401,7 @@ class PmsProperty(models.Model): property_client_conf = self.env["ota.property.settings"].search( [ ("pms_property_id", "=", pms_property_id), - ("agency_id", "=", client.id), + ("agency_id", "=", client.partner_id.id), ] ) rules_records = self.env["pms.availability.plan.rule"].search( @@ -437,7 +437,8 @@ class PmsProperty(models.Model): current_date_from = date current_date_to = date elif ( - current_rule.min_stay == rule.min_stay + rule + and current_rule.min_stay == rule.min_stay and current_rule.max_stay == rule.max_stay and current_rule.closed == rule.closed and current_rule.closed_arrival == rule.closed_arrival @@ -488,7 +489,7 @@ class PmsProperty(models.Model): property_client_conf = self.env["ota.property.settings"].search( [ ("pms_property_id", "=", pms_property_id), - ("agency_id", "=", client.id), + ("agency_id", "=", client.partner_id.id), ] ) pms_property = self.env["pms.property"].browse(pms_property_id) @@ -572,12 +573,6 @@ class PmsProperty(models.Model): clients = client else: clients = self.env["res.users"].search([("pms_api_client", "=", True)]) - property_client_conf = self.env["ota.property.settings"].search( - [ - ("pms_property_id", "in", clients.pms_property_ids.ids), - ("agency_id", "in", clients.ids), - ] - ) _logger.info("PMS API push batch") if isinstance(date_from, str): date_from = datetime.datetime.strptime(date_from, "%Y-%m-%d").date() @@ -598,6 +593,12 @@ class PmsProperty(models.Model): ] ) for pms_property in pms_properties: + property_client_conf = self.env["ota.property.settings"].search( + [ + ("pms_property_id", "=", pms_property.id), + ("agency_id", "=", client.partner_id.id), + ] + ) pms_property_id = pms_property.id room_type_ids = ( [filter_room_type_id] diff --git a/pms_api_rest/services/pms_sale_channel_service.py b/pms_api_rest/services/pms_sale_channel_service.py index fa8dd999b..d336874ec 100644 --- a/pms_api_rest/services/pms_sale_channel_service.py +++ b/pms_api_rest/services/pms_sale_channel_service.py @@ -51,6 +51,8 @@ class PmsSaleChannelService(Component): domain = [ ("id", "in", sale_channels_total), ] + if sale_channel_search_param.isOnLine: + domain.append(("is_on_line", "=", sale_channel_search_param.isOnLine)) result_sale_channels = [] PmsSaleChannelInfo = self.env.datamodels["pms.sale.channel.info"] @@ -67,6 +69,7 @@ class PmsSaleChannelService(Component): iconUrl=url_image_pms_api_rest( "pms.sale.channel", sale_channel.id, "icon" ), + isOnLine=sale_channel.is_on_line, ) ) return result_sale_channels