mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[REF] pms_api_rest: consistency in datamodels and services filenames
This commit is contained in:
committed by
Darío Lodeiros
parent
8fb04c9179
commit
d8db62c4b7
52
pms_api_rest/services/pms_room_service.py
Normal file
52
pms_api_rest/services/pms_room_service.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from odoo.addons.base_rest import restapi
|
||||
from odoo.addons.base_rest_datamodel.restapi import Datamodel
|
||||
from odoo.addons.component.core import Component
|
||||
|
||||
|
||||
class PmsRoomService(Component):
|
||||
_inherit = "base.rest.service"
|
||||
_name = "pms.room.service"
|
||||
_usage = "rooms"
|
||||
_collection = "pms.services"
|
||||
|
||||
@restapi.method(
|
||||
[
|
||||
(
|
||||
[
|
||||
"/",
|
||||
],
|
||||
"GET",
|
||||
)
|
||||
],
|
||||
input_param=Datamodel("pms.room.search.param"),
|
||||
output_param=Datamodel("pms.room.info", is_list=True),
|
||||
auth="jwt_api_pms",
|
||||
)
|
||||
def get_rooms(self, room_search_param):
|
||||
domain = []
|
||||
if room_search_param.name:
|
||||
domain.append(("name", "like", room_search_param.name))
|
||||
if room_search_param.id:
|
||||
domain.append(("id", "=", room_search_param.id))
|
||||
if room_search_param.pms_property_id:
|
||||
domain.append(("pms_property_id", "=", room_search_param.pms_property_id))
|
||||
|
||||
result_rooms = []
|
||||
PmsRoomInfo = self.env.datamodels["pms.room.info"]
|
||||
for room in (
|
||||
self.env["pms.room"]
|
||||
.sudo()
|
||||
.search(
|
||||
domain,
|
||||
)
|
||||
):
|
||||
|
||||
result_rooms.append(
|
||||
PmsRoomInfo(
|
||||
id=room.id,
|
||||
name=room.name,
|
||||
roomTypeId=room.room_type_id,
|
||||
capacity=room.capacity,
|
||||
)
|
||||
)
|
||||
return result_rooms
|
||||
Reference in New Issue
Block a user