[FIX]pms_api_rest: ubications&room_type_class GET services by property

This commit is contained in:
Darío Lodeiros
2022-11-15 01:18:12 +01:00
parent f3812b2b38
commit f220a3d42c
2 changed files with 27 additions and 46 deletions

View File

@@ -23,36 +23,28 @@ class PmsRoomTypeClassService(Component):
auth="jwt_api_pms",
)
def get_room_type_class(self, room_type_class_search_param):
room_type_class_all_properties = self.env["pms.room.type.class"].search(
[("pms_property_ids", "=", False)]
)
if room_type_class_search_param.pmsPropertyIds:
room_type_class = set()
for index, prop in enumerate(room_type_class_search_param.pmsPropertyds):
room_type_class_with_query_property = self.env[
"pms.room.type.class"
].search([("pms_property_ids", "=", prop)])
if index == 0:
room_type_class = set(room_type_class_with_query_property.ids)
else:
room_type_class = room_type_class.intersection(
set(room_type_class_with_query_property.ids)
)
room_type_class_total = list(
set(list(room_type_class) + room_type_class_all_properties.ids)
room_type_classes = (
self.env["pms.room"]
.search(
[
(
"pms_property_id",
"in",
room_type_class_search_param.pmsPropertyIds,
)
]
)
.mapped("room_type_id")
.mapped("class_id")
)
else:
room_type_class_total = list(room_type_class_all_properties.ids)
domain = [
("id", "in", room_type_class_total),
]
room_type_classes = self.env["pms.room.type.class"].search(
[("pms_property_ids", "=", False)]
)
result_room_type_class = []
PmsRoomTypeClassInfo = self.env.datamodels["pms.room.type.class.info"]
for room in self.env["pms.room.type.class"].search(
domain,
):
for room in room_type_classes:
result_room_type_class.append(
PmsRoomTypeClassInfo(
id=room.id,

View File

@@ -23,33 +23,22 @@ class PmsUbicationService(Component):
auth="jwt_api_pms",
)
def get_ubications(self, ubication_search_param):
ubication_all_properties = self.env["pms.ubication"].search(
[("pms_property_ids", "=", False)]
)
if ubication_search_param.pmsPropertyIds:
ubication = set()
for index, prop in enumerate(ubication_search_param.pmsPropertyIds):
ubication_with_query_property = self.env["pms.ubication"].search(
[("pms_property_ids", "=", prop)]
ubications = (
self.env["pms.room"]
.search(
[("pms_property_id", "in", ubication_search_param.pmsPropertyIds)]
)
if index == 0:
ubication = set(ubication_with_query_property.ids)
else:
ubication = ubication.intersection(
set(ubication_with_query_property.ids)
)
ubication_total = list(set(list(ubication) + ubication_all_properties.ids))
.mapped("ubication_id")
)
else:
ubication_total = list(ubication_all_properties.ids)
domain = [
("id", "in", ubication_total),
]
ubications = self.env["pms.ubication"].search(
[("pms_property_ids", "=", False)]
)
result_ubications = []
PmsUbicationInfo = self.env.datamodels["pms.ubication.info"]
for ubication in self.env["pms.ubication"].search(
domain,
):
for ubication in ubications:
result_ubications.append(
PmsUbicationInfo(