[ADD]pms_api_rest: sale_channel_service isOnLine search param

This commit is contained in:
Darío Lodeiros
2024-03-02 18:11:49 +01:00
parent 2c04ff219e
commit df1be8420a
3 changed files with 17 additions and 11 deletions

View File

@@ -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)

View File

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

View File

@@ -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