[REF]pms_api_rest: api rest routes and datamodel names refactor

This commit is contained in:
braisab
2022-07-06 20:11:25 +02:00
committed by Darío Lodeiros
parent 74578e1c1a
commit 78bdc6a31a
25 changed files with 91 additions and 91 deletions

View File

@@ -7,4 +7,4 @@ class PmsAccountJournalInfo(Datamodel):
_name = "pms.account.journal.info"
id = fields.Integer(required=False, allow_none=True)
name = fields.String(required=False, allow_none=True)
allowed_pms_payments = fields.Boolean(required=False, allow_none=True)
allowedPmsPayments = fields.Boolean(required=False, allow_none=True)

View File

@@ -7,4 +7,4 @@ class PmsAvailabilityPlanInfo(Datamodel):
_name = "pms.availability.plan.info"
id = fields.Integer(required=False, allow_none=True)
name = fields.String(required=False, allow_none=True)
pms_property_ids = fields.List(fields.Integer(required=False, allow_none=True))
pmsPropertyIds = fields.List(fields.Integer(required=False, allow_none=True))

View File

@@ -5,9 +5,9 @@ from odoo.addons.datamodel.core import Datamodel
class PmsAvailabilityPlanRuleSearchParam(Datamodel):
_name = "pms.availability.plan.rule.search.param"
date_from = fields.String(required=True, allow_none=False)
date_to = fields.String(required=True, allow_none=False)
pms_property_id = fields.Integer(required=True, allow_none=False)
dateFrom = fields.String(required=True, allow_none=False)
dateTo = fields.String(required=True, allow_none=False)
pmsPropertyId = fields.Integer(required=True, allow_none=False)
class PmsAvailabilityPlanRuleInfo(Datamodel):

View File

@@ -20,15 +20,15 @@ class PmsCalendarSwapInfo(Datamodel):
swapTo = fields.String(required=True, allow_none=False)
roomIdA = fields.Integer(required=True, allow_none=False)
roomIdB = fields.Integer(required=True, allow_none=False)
pms_property_id = fields.Integer(required=False, allow_none=True)
pmsPropertyId = fields.Integer(required=False, allow_none=True)
class PmsCalendarSearchParam(Datamodel):
_name = "pms.calendar.search.param"
date_from = fields.String(required=False, allow_none=True)
date_to = fields.String(required=False, allow_none=True)
pms_property_id = fields.Integer(required=True, allow_none=False)
pricelist_id = fields.Integer(required=False, allow_none=True)
dateFrom = fields.String(required=False, allow_none=True)
dateTo = fields.String(required=False, allow_none=True)
pmsPropertyId = fields.Integer(required=True, allow_none=False)
pricelistId = fields.Integer(required=False, allow_none=True)
class PmsCalendarFreeDailyRoomsByType(Datamodel):

View File

@@ -6,9 +6,9 @@ from odoo.addons.datamodel.core import Datamodel
class PmsFolioSearchParam(Datamodel):
_name = "pms.folio.search.param"
pms_property_id = fields.Integer(required=True, allow_none=True)
date_from = fields.String(required=False, allow_none=True)
date_to = fields.String(required=False, allow_none=True)
pmsPropertyId = fields.Integer(required=True, allow_none=True)
dateFrom = fields.String(required=False, allow_none=True)
dateTo = fields.String(required=False, allow_none=True)
filter = fields.String(required=False, allow_none=True)

View File

@@ -7,4 +7,4 @@ class PmsPricelistInfo(Datamodel):
_name = "pms.pricelist.info"
id = fields.Integer(required=False, allow_none=True)
name = fields.String(required=False, allow_none=True)
pms_property_ids = fields.List(fields.Integer(required=False, allow_none=True))
pmsPropertyIds = fields.List(fields.Integer(required=False, allow_none=True))

View File

@@ -5,9 +5,9 @@ from odoo.addons.datamodel.core import Datamodel
class PmsPricelistItemSearchParam(Datamodel):
_name = "pms.pricelist.item.search.param"
date_from = fields.String(required=True, allow_none=False)
date_to = fields.String(required=True, allow_none=False)
pms_property_id = fields.Integer(required=True, allow_none=False)
dateFrom = fields.String(required=True, allow_none=False)
dateTo = fields.String(required=True, allow_none=False)
pmsPropertyId = fields.Integer(required=True, allow_none=False)
class PmsPricelistItemInfo(Datamodel):

View File

@@ -21,9 +21,9 @@ class PmsReservationInfo(Datamodel):
pricelistId = fields.Integer(required=False, allow_none=True)
services = fields.List(fields.Dict(required=False, allow_none=True))
messages = fields.List(fields.Dict(required=False, allow_none=True))
pms_property_id = fields.Integer(required=False, allow_none=True)
pmsPropertyId = fields.Integer(required=False, allow_none=True)
boardServiceId = fields.Integer(required=False, allow_none=True)
boardServiceName = fields.String(required=False, allow_none=True)
channelTypeId = fields.Integer(required=False, allow_none=True)
adults = fields.Integer(required=False, allow_none=True)
Overbooking = fields.Boolean(required=False, allow_none=True)
overbooking = fields.Boolean(required=False, allow_none=True)

View File

@@ -7,7 +7,7 @@ class PmsRoomSearchParam(Datamodel):
_name = "pms.room.search.param"
id = fields.Integer(required=False, allow_none=False)
name = fields.String(required=False, allow_none=False)
pms_property_id = fields.Integer(required=True, allow_none=False)
pmsPropertyId = fields.Integer(required=True, allow_none=False)
availabilityFrom = fields.String(required=False, allow_none=False)
availabilityTo = fields.String(required=False, allow_none=False)
currentLines = fields.List(fields.Integer(), required=False, allow_none=False)

View File

@@ -7,13 +7,13 @@ class PmsRoomTypeSearchParam(Datamodel):
_name = "pms.room.type.search.param"
id = fields.Integer(required=False, allow_none=True)
name = fields.String(required=False, allow_none=True)
pms_property_ids = fields.List(fields.Integer(), required=False)
pmsPropertyIds = fields.List(fields.Integer(), required=False)
class PmsRoomTypeInfo(Datamodel):
_name = "pms.room.type.info"
id = fields.Integer(required=False, allow_none=True)
name = fields.String(required=False, allow_none=True)
pms_property_ids = fields.List(fields.Integer(), required=False)
pmsPropertyIds = fields.List(fields.Integer(), required=False)
defaultCode = fields.String(required=False, allow_none=True)
price = fields.Float(required=False, allow_none=True)

View File

@@ -7,11 +7,11 @@ class PmsRoomTypeClassSearchParam(Datamodel):
_name = "pms.room.type.class.search.param"
id = fields.Integer(required=False, allow_none=True)
name = fields.String(required=False, allow_none=True)
pms_property_ids = fields.List(fields.Integer(), required=False)
pmsPropertyIds = fields.List(fields.Integer(), required=False)
class PmsRoomTypeClassInfo(Datamodel):
_name = "pms.room.type.class.info"
id = fields.Integer(required=False, allow_none=True)
name = fields.String(required=False, allow_none=True)
pms_property_ids = fields.List(fields.Integer(), required=False)
pmsPropertyIds = fields.List(fields.Integer(), required=False)

View File

@@ -6,5 +6,5 @@ from odoo.addons.datamodel.core import Datamodel
class PmsSearchParam(Datamodel):
_name = "pms.search.param"
pms_property_id = fields.Integer(required=False, allow_none=True)
pms_property_ids = fields.List(fields.Integer(), required=False)
pmsPropertyId = fields.Integer(required=False, allow_none=True)
pmsPropertyIds = fields.List(fields.Integer(), required=False)

View File

@@ -7,11 +7,11 @@ class PmsUbicationSearchParam(Datamodel):
_name = "pms.ubication.search.param"
id = fields.Integer(required=False, allow_none=True)
name = fields.String(required=False, allow_none=True)
pms_property_ids = fields.List(fields.Integer(), required=False)
pmsPropertyIds = fields.List(fields.Integer(), required=False)
class PmsUbicationInfo(Datamodel):
_name = "pms.ubication.info"
id = fields.Integer(required=False, allow_none=True)
name = fields.String(required=False, allow_none=True)
pms_property_ids = fields.List(fields.Integer(), required=False)
pmsPropertyIds = fields.List(fields.Integer(), required=False)

View File

@@ -32,8 +32,8 @@ class PmsAvailabilityPlanService(Component):
[("pms_property_ids", "=", False)]
)
availabilities = set()
if pms_search_param.pms_property_ids:
for index, prop in enumerate(pms_search_param.pms_property_ids):
if pms_search_param.pmsPropertyIds:
for index, prop in enumerate(pms_search_param.pmsPropertyIds):
availabilities_with_query_property = self.env[
"pms.availability.plan"
].search([("pms_property_ids", "=", prop)])
@@ -59,7 +59,7 @@ class PmsAvailabilityPlanService(Component):
PmsAvialabilityPlanInfo(
id=availability.id,
name=availability.name,
pms_property_ids=availability.pms_property_ids.mapped("id"),
pmsPropertyIds=availability.pms_property_ids.mapped("id"),
)
)
return result_availabilities
@@ -92,15 +92,15 @@ class PmsAvailabilityPlanService(Component):
(
"pms_property_id",
"=",
availability_plan_rule_search_param.pms_property_id,
availability_plan_rule_search_param.pmsPropertyId,
)
]
)
date_from = datetime.strptime(
availability_plan_rule_search_param.date_from, "%Y-%m-%d"
availability_plan_rule_search_param.dateFrom, "%Y-%m-%d"
).date()
date_to = datetime.strptime(
availability_plan_rule_search_param.date_to, "%Y-%m-%d"
availability_plan_rule_search_param.dateTo, "%Y-%m-%d"
).date()
for date in (

View File

@@ -106,14 +106,14 @@ class PmsBoardServiceService(Component):
def get_board_service_lines(self, board_service_id, pms_search_param):
domain = list()
domain.append(("pms_board_service_room_type_id", "=", board_service_id))
if pms_search_param.pms_property_id:
if pms_search_param.pmsPropertyId:
domain.extend(
[
"|",
(
"pms_property_ids",
"in",
pms_search_param.pms_property_id,
pms_search_param.pmsPropertyId,
),
("pms_property_ids", "=", False),
]

View File

@@ -26,9 +26,9 @@ class PmsCalendarService(Component):
)
def get_calendar(self, calendar_search_param):
domain = list()
domain.append(("date", ">=", calendar_search_param.date_from))
domain.append(("date", "<=", calendar_search_param.date_to))
domain.append(("pms_property_id", "=", calendar_search_param.pms_property_id))
domain.append(("date", ">=", calendar_search_param.dateFrom))
domain.append(("date", "<=", calendar_search_param.dateTo))
domain.append(("pms_property_id", "=", calendar_search_param.pmsPropertyId))
domain.append(("state", "!=", "cancel"))
result_lines = []
PmsCalendarInfo = self.env.datamodels["pms.calendar.info"]
@@ -117,7 +117,7 @@ class PmsCalendarService(Component):
("room_id", "=", room_id_b),
("date", ">=", swap_info.swapFrom),
("date", "<=", swap_info.swapTo),
("pms_property_id", "=", swap_info.pms_property_id),
("pms_property_id", "=", swap_info.pmsPropertyId),
]
)
lines_room_a.occupies_availability = False
@@ -146,24 +146,24 @@ class PmsCalendarService(Component):
def get_daily_invoincing(self, pms_calendar_search_param):
reservation_lines = self.env["pms.reservation.line"].search(
[
("date", ">=", pms_calendar_search_param.date_from),
("date", "<=", pms_calendar_search_param.date_to),
("pms_property_id", "=", pms_calendar_search_param.pms_property_id),
("date", ">=", pms_calendar_search_param.dateFrom),
("date", "<=", pms_calendar_search_param.dateTo),
("pms_property_id", "=", pms_calendar_search_param.pmsPropertyId),
]
)
service_lines = self.env["pms.service.line"].search(
[
("date", ">=", pms_calendar_search_param.date_from),
("date", "<=", pms_calendar_search_param.date_to),
("pms_property_id", "=", pms_calendar_search_param.pms_property_id),
("date", ">=", pms_calendar_search_param.dateFrom),
("date", "<=", pms_calendar_search_param.dateTo),
("pms_property_id", "=", pms_calendar_search_param.pmsPropertyId),
]
)
date_from = datetime.strptime(
pms_calendar_search_param.date_from, "%Y-%m-%d"
pms_calendar_search_param.dateFrom, "%Y-%m-%d"
).date()
date_to = datetime.strptime(
pms_calendar_search_param.date_to, "%Y-%m-%d"
pms_calendar_search_param.dateTo, "%Y-%m-%d"
).date()
result = []
@@ -201,10 +201,10 @@ class PmsCalendarService(Component):
def get_free_rooms(self, pms_calendar_search_param):
date_from = datetime.strptime(
pms_calendar_search_param.date_from, "%Y-%m-%d"
pms_calendar_search_param.dateFrom, "%Y-%m-%d"
).date()
date_to = datetime.strptime(
pms_calendar_search_param.date_to, "%Y-%m-%d"
pms_calendar_search_param.dateTo, "%Y-%m-%d"
).date()
result = []
PmsCalendarFreeDailyRoomsByType = self.env.datamodels[
@@ -214,7 +214,7 @@ class PmsCalendarService(Component):
date_from + timedelta(d) for d in range((date_to - date_from).days + 1)
):
rooms = self.env["pms.room"].search(
[("pms_property_id", "=", pms_calendar_search_param.pms_property_id)]
[("pms_property_id", "=", pms_calendar_search_param.pmsPropertyId)]
)
for room_type_iterator in self.env["pms.room.type"].search(
[("id", "in", rooms.mapped("room_type_id").ids)]
@@ -227,7 +227,7 @@ class PmsCalendarService(Component):
(
"pms_property_id",
"=",
pms_calendar_search_param.pms_property_id,
pms_calendar_search_param.pmsPropertyId,
),
]
)
@@ -236,7 +236,7 @@ class PmsCalendarService(Component):
(
"pms_property_id",
"=",
pms_calendar_search_param.pms_property_id,
pms_calendar_search_param.pmsPropertyId,
),
("room_type_id", "=", room_type_iterator.id),
]
@@ -274,10 +274,10 @@ class PmsCalendarService(Component):
def get_alerts_per_day(self, pms_calendar_search_param):
PmsCalendarAlertsPerDay = self.env.datamodels["pms.calendar.alerts.per.day"]
date_from = datetime.strptime(
pms_calendar_search_param.date_from, "%Y-%m-%d"
pms_calendar_search_param.dateFrom, "%Y-%m-%d"
).date()
date_to = datetime.strptime(
pms_calendar_search_param.date_to, "%Y-%m-%d"
pms_calendar_search_param.dateTo, "%Y-%m-%d"
).date()
result = []
for day in (
@@ -286,7 +286,7 @@ class PmsCalendarService(Component):
lines = self.env["pms.reservation.line"].search_count(
[
("date", "=", day),
("pms_property_id", "=", pms_calendar_search_param.pms_property_id),
("pms_property_id", "=", pms_calendar_search_param.pmsPropertyId),
("overbooking", "=", True),
]
)

View File

@@ -30,16 +30,16 @@ class PmsFolioService(Component):
domain_fields = list()
domain_fields.append(
("pms_property_id", "=", folio_search_param.pms_property_id)
("pms_property_id", "=", folio_search_param.pmsPropertyId)
)
if folio_search_param.date_to and folio_search_param.date_from:
if folio_search_param.dateTo and folio_search_param.dateFrom:
reservation_lines = (
self.env["pms.reservation.line"]
.search(
[
("date", ">=", folio_search_param.date_from),
("date", "<", folio_search_param.date_to),
("date", ">=", folio_search_param.dateFrom),
("date", "<", folio_search_param.dateTo),
]
)
.mapped("reservation_id")
@@ -107,7 +107,7 @@ class PmsFolioService(Component):
).isoformat(),
"preferredRoomId": reservation.preferred_room_id.id
if reservation.preferred_room_id
else "",
else 0,
"preferredRoomCapacity": reservation.preferred_room_id.capacity
if reservation.preferred_room_id
else "",
@@ -219,7 +219,7 @@ class PmsFolioService(Component):
def get_folio_payments(self, folio_id, pms_search_param):
domain = list()
domain.append(("id", "=", folio_id))
domain.append(("pms_property_id", "=", pms_search_param.pms_property_id))
domain.append(("pms_property_id", "=", pms_search_param.pmsPropertyId))
folio = self.env["pms.folio"].search(domain)
payments = []
PmsPaymentInfo = self.env.datamodels["pms.payment.info"]
@@ -271,7 +271,7 @@ class PmsFolioService(Component):
reservation = self.env["pms.reservation"].create(
{
"partner_name": pms_reservation_info.partner,
"pms_property_id": pms_reservation_info.pms_property_id,
"pms_property_id": pms_reservation_info.pmsPropertyId,
"room_type_id": pms_reservation_info.roomTypeId,
"pricelist_id": pms_reservation_info.pricelistId,
"checkin": pms_reservation_info.checkin,

View File

@@ -32,9 +32,9 @@ class PmsPricelistService(Component):
pricelists_all_properties = self.env["product.pricelist"].search(
[("pms_property_ids", "=", False)]
)
if pms_search_param.pms_property_ids:
if pms_search_param.pmsPropertyIds:
pricelists = set()
for index, prop in enumerate(pms_search_param.pms_property_ids):
for index, prop in enumerate(pms_search_param.pmsPropertyIds):
pricelists_with_query_property = self.env["product.pricelist"].search(
[("pms_property_ids", "=", prop)]
)
@@ -60,7 +60,7 @@ class PmsPricelistService(Component):
PmsPricelistInfo(
id=pricelist.id,
name=pricelist.name,
pms_property_ids=pricelist.pms_property_ids.mapped("id"),
pmsPropertyIds=pricelist.pms_property_ids.mapped("id"),
)
)
return result_pricelists
@@ -87,13 +87,13 @@ class PmsPricelistService(Component):
raise MissingError
PmsPricelistItemInfo = self.env.datamodels["pms.pricelist.item.info"]
rooms = self.env["pms.room"].search(
[("pms_property_id", "=", pricelist_item_search_param.pms_property_id)]
[("pms_property_id", "=", pricelist_item_search_param.pmsPropertyId)]
)
date_from = datetime.strptime(
pricelist_item_search_param.date_from, "%Y-%m-%d"
pricelist_item_search_param.dateFrom, "%Y-%m-%d"
).date()
date_to = datetime.strptime(
pricelist_item_search_param.date_to, "%Y-%m-%d"
pricelist_item_search_param.dateTo, "%Y-%m-%d"
).date()
for date in (

View File

@@ -96,7 +96,7 @@ class PmsPropertyService(Component):
[
(
[
"/<int:property_id>/paymentmethods",
"/<int:property_id>/payment-methods",
],
"GET",
)
@@ -120,7 +120,7 @@ class PmsPropertyService(Component):
PmsAccountJournalInfo(
id=payment_method.id,
name=payment_method.name,
allowed_pms_payments=payment_method.allowed_pms_payments,
allowedPmsPayments=payment_method.allowed_pms_payments,
)
)
return res

View File

@@ -27,8 +27,8 @@ class PmsReservationService(Component):
def get_reservation(self, reservation_id, pms_search_param):
domain = list()
domain.append(("id", "=", reservation_id))
if pms_search_param.pms_property_id:
domain.append(("pms_property_id", "=", pms_search_param.pms_property_id))
if pms_search_param.pmsPropertyId:
domain.append(("pms_property_id", "=", pms_search_param.pmsPropertyId))
reservation = self.env["pms.reservation"].search(domain)
res = []
PmsReservationInfo = self.env.datamodels["pms.reservation.info"]
@@ -233,7 +233,7 @@ class PmsReservationService(Component):
[
(
[
"/<int:reservation_id>/checkinpartners",
"/<int:reservation_id>/checkin-partners",
],
"GET",
)
@@ -314,7 +314,7 @@ class PmsReservationService(Component):
[
(
[
"/<int:reservation_id>/checkin_partners/<int:checkin_partner_id>",
"/<int:reservation_id>/checkin-partners/<int:checkin_partner_id>",
],
"PATCH",
)
@@ -337,7 +337,7 @@ class PmsReservationService(Component):
[
(
[
"/<int:reservation_id>/checkin_partners",
"/<int:reservation_id>/checkin-partners",
],
"POST",
)
@@ -368,7 +368,7 @@ class PmsReservationService(Component):
[
(
[
"/<int:reservation_id>/checkin_partners/<int:checkin_partner_id>",
"/<int:reservation_id>/checkin-partners/<int:checkin_partner_id>",
],
"DELETE",
)

View File

@@ -33,12 +33,12 @@ class PmsRoomService(Component):
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))
if room_search_param.pmsPropertyId:
domain.append(("pms_property_id", "=", room_search_param.pmsPropertyId))
if (
room_search_param.availabilityFrom
and room_search_param.availabilityTo
and room_search_param.pms_property_id
and room_search_param.pmsPropertyId
and room_search_param.pricelistId
):
date_from = datetime.strptime(
@@ -48,7 +48,7 @@ class PmsRoomService(Component):
room_search_param.availabilityTo, "%Y-%m-%d"
).date()
pms_property = self.env["pms.property"].browse(
room_search_param.pms_property_id
room_search_param.pmsPropertyId
)
pms_property = pms_property.with_context(
checkin=date_from,

View File

@@ -26,9 +26,9 @@ class PmsRoomTypeClassService(Component):
room_type_class_all_properties = self.env["pms.room.type.class"].search(
[("pms_property_ids", "=", False)]
)
if room_type_class_search_param.pms_property_ids:
if room_type_class_search_param.pmsPropertyIds:
room_type_class = set()
for index, prop in enumerate(room_type_class_search_param.pms_property_ids):
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)])
@@ -57,7 +57,7 @@ class PmsRoomTypeClassService(Component):
PmsRoomTypeClassInfo(
id=room.id,
name=room.name,
pms_property_ids=room.pms_property_ids.mapped("id"),
pmsPropertyIds=room.pms_property_ids.mapped("id"),
)
)
return result_room_type_class

View File

@@ -26,9 +26,9 @@ class PmsRoomTypeService(Component):
room_type_all_properties = self.env["pms.room.type"].search(
[("pms_property_ids", "=", False)]
)
if room_type_search_param.pms_property_ids:
if room_type_search_param.pmsPropertyIds:
room_types = set()
for index, prop in enumerate(room_type_search_param.pms_property_ids):
for index, prop in enumerate(room_type_search_param.pmsPropertyIds):
room_types_with_query_property = self.env["pms.room.type"].search(
[("pms_property_ids", "=", prop)]
)
@@ -57,7 +57,7 @@ class PmsRoomTypeService(Component):
PmsRoomTypeInfo(
id=room.id,
name=room.name,
pms_property_ids=room.pms_property_ids.mapped("id"),
pmsPropertyIds=room.pms_property_ids.mapped("id"),
defaultCode=room.default_code,
price=room.list_price,
)

View File

@@ -26,9 +26,9 @@ class PmsUbicationService(Component):
ubication_all_properties = self.env["pms.ubication"].search(
[("pms_property_ids", "=", False)]
)
if ubication_search_param.pms_property_ids:
if ubication_search_param.pmsPropertyIds:
ubication = set()
for index, prop in enumerate(ubication_search_param.pms_property_ids):
for index, prop in enumerate(ubication_search_param.pmsPropertyIds):
ubication_with_query_property = self.env["pms.ubication"].search(
[("pms_property_ids", "=", prop)]
)
@@ -55,7 +55,7 @@ class PmsUbicationService(Component):
PmsUbicationInfo(
id=room.id,
name=room.name,
pms_property_ids=room.pms_property_ids.mapped("id"),
pmsPropertyIds=room.pms_property_ids.mapped("id"),
)
)
return result_ubications

View File

@@ -37,7 +37,7 @@ class ResCountryService(Component):
[
(
[
"/<int:country_id>/country_states",
"/<int:country_id>/country-states",
],
"GET",
)