mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD]pms_api_rest: sale_channel_service isOnLine search param
This commit is contained in:
@@ -6,6 +6,7 @@ from odoo.addons.datamodel.core import Datamodel
|
|||||||
class PmsSaleChannelSearchParam(Datamodel):
|
class PmsSaleChannelSearchParam(Datamodel):
|
||||||
_name = "pms.sale.channel.search.param"
|
_name = "pms.sale.channel.search.param"
|
||||||
pmsPropertyIds = fields.List(fields.Integer(), required=False)
|
pmsPropertyIds = fields.List(fields.Integer(), required=False)
|
||||||
|
IsOnLine = fields.Boolean(required=False, allow_none=True)
|
||||||
|
|
||||||
|
|
||||||
class PmsSaleChannelInfo(Datamodel):
|
class PmsSaleChannelInfo(Datamodel):
|
||||||
@@ -14,3 +15,4 @@ class PmsSaleChannelInfo(Datamodel):
|
|||||||
name = fields.String(required=True, allow_none=False)
|
name = fields.String(required=True, allow_none=False)
|
||||||
channelType = fields.String(required=True, allow_none=True)
|
channelType = fields.String(required=True, allow_none=True)
|
||||||
iconUrl = fields.String(required=False, allow_none=True)
|
iconUrl = fields.String(required=False, allow_none=True)
|
||||||
|
isOnLine = fields.Boolean(required=True, allow_none=False)
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class PmsProperty(models.Model):
|
|||||||
property_client_conf = self.env["ota.property.settings"].search(
|
property_client_conf = self.env["ota.property.settings"].search(
|
||||||
[
|
[
|
||||||
("pms_property_id", "=", self.id),
|
("pms_property_id", "=", self.id),
|
||||||
("agency_id", "=", client.id),
|
("agency_id", "=", client.partner_id.id),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
plan_avail = property_client_conf.main_avail_plan_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(
|
property_client_conf = self.env["ota.property.settings"].search(
|
||||||
[
|
[
|
||||||
("pms_property_id", "=", pms_property_id),
|
("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
|
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(
|
property_client_conf = self.env["ota.property.settings"].search(
|
||||||
[
|
[
|
||||||
("pms_property_id", "=", pms_property_id),
|
("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(
|
rules_records = self.env["pms.availability.plan.rule"].search(
|
||||||
@@ -437,7 +437,8 @@ class PmsProperty(models.Model):
|
|||||||
current_date_from = date
|
current_date_from = date
|
||||||
current_date_to = date
|
current_date_to = date
|
||||||
elif (
|
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.max_stay == rule.max_stay
|
||||||
and current_rule.closed == rule.closed
|
and current_rule.closed == rule.closed
|
||||||
and current_rule.closed_arrival == rule.closed_arrival
|
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(
|
property_client_conf = self.env["ota.property.settings"].search(
|
||||||
[
|
[
|
||||||
("pms_property_id", "=", pms_property_id),
|
("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)
|
pms_property = self.env["pms.property"].browse(pms_property_id)
|
||||||
@@ -572,12 +573,6 @@ class PmsProperty(models.Model):
|
|||||||
clients = client
|
clients = client
|
||||||
else:
|
else:
|
||||||
clients = self.env["res.users"].search([("pms_api_client", "=", True)])
|
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")
|
_logger.info("PMS API push batch")
|
||||||
if isinstance(date_from, str):
|
if isinstance(date_from, str):
|
||||||
date_from = datetime.datetime.strptime(date_from, "%Y-%m-%d").date()
|
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:
|
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
|
pms_property_id = pms_property.id
|
||||||
room_type_ids = (
|
room_type_ids = (
|
||||||
[filter_room_type_id]
|
[filter_room_type_id]
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ class PmsSaleChannelService(Component):
|
|||||||
domain = [
|
domain = [
|
||||||
("id", "in", sale_channels_total),
|
("id", "in", sale_channels_total),
|
||||||
]
|
]
|
||||||
|
if sale_channel_search_param.isOnLine:
|
||||||
|
domain.append(("is_on_line", "=", sale_channel_search_param.isOnLine))
|
||||||
|
|
||||||
result_sale_channels = []
|
result_sale_channels = []
|
||||||
PmsSaleChannelInfo = self.env.datamodels["pms.sale.channel.info"]
|
PmsSaleChannelInfo = self.env.datamodels["pms.sale.channel.info"]
|
||||||
@@ -67,6 +69,7 @@ class PmsSaleChannelService(Component):
|
|||||||
iconUrl=url_image_pms_api_rest(
|
iconUrl=url_image_pms_api_rest(
|
||||||
"pms.sale.channel", sale_channel.id, "icon"
|
"pms.sale.channel", sale_channel.id, "icon"
|
||||||
),
|
),
|
||||||
|
isOnLine=sale_channel.is_on_line,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return result_sale_channels
|
return result_sale_channels
|
||||||
|
|||||||
Reference in New Issue
Block a user