mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] pms_api_rest: add cancellation flow and more
This commit is contained in:
committed by
Darío Lodeiros
parent
41a1df4fda
commit
f904489e62
@@ -1,4 +1,5 @@
|
|||||||
from odoo.addons.base_rest.controllers import main
|
from odoo.addons.base_rest.controllers import main
|
||||||
|
|
||||||
from ..lib_jwt.jwt_http import jwt_http
|
from ..lib_jwt.jwt_http import jwt_http
|
||||||
from ..lib_jwt.validator import validator
|
from ..lib_jwt.validator import validator
|
||||||
|
|
||||||
|
|||||||
@@ -14,4 +14,12 @@ class PmsReservationShortInfo(Datamodel):
|
|||||||
roomTypeId = fields.String(required=True, allow_none=False)
|
roomTypeId = fields.String(required=True, allow_none=False)
|
||||||
name = fields.String(required=True, allow_none=False)
|
name = fields.String(required=True, allow_none=False)
|
||||||
partnerRequests = fields.String(required=False, allow_none=True)
|
partnerRequests = fields.String(required=False, allow_none=True)
|
||||||
pwaActionButtons = fields.Dict(required=False, allow_none=True)
|
state = fields.String(required=True, allow_none=False)
|
||||||
|
priceTotal = fields.Float(required=True, allow_none=True)
|
||||||
|
adults = fields.Integer(required=True, allow_none=False)
|
||||||
|
channelTypeId = fields.String(required=False, allow_none=True)
|
||||||
|
agencyId = fields.String(required=False, allow_none=True)
|
||||||
|
boardServiceId = fields.String(required=False, allow_none=True)
|
||||||
|
checkinsRatio = fields.Float(required=True, allow_none=False)
|
||||||
|
outstanding = fields.Float(required=True, allow_none=False)
|
||||||
|
pwaActionButtons = fields.Dict(required=True, allow_none=False)
|
||||||
|
|||||||
@@ -55,9 +55,41 @@ class PmsReservationService(Component):
|
|||||||
partnerRequests=reservation.partner_requests
|
partnerRequests=reservation.partner_requests
|
||||||
if reservation.partner_requests
|
if reservation.partner_requests
|
||||||
else "",
|
else "",
|
||||||
|
state=dict(reservation.fields_get(["state"])["state"]["selection"])[
|
||||||
|
reservation.state
|
||||||
|
],
|
||||||
|
priceTotal=reservation.price_total,
|
||||||
|
adults=reservation.adults,
|
||||||
|
channelTypeId=reservation.channel_type_id
|
||||||
|
if reservation.channel_type_id
|
||||||
|
else "",
|
||||||
|
agencyId=reservation.agency_id if reservation.agency_id else "",
|
||||||
|
boardServiceId=reservation.board_service_room_id.pms_board_service_id.name
|
||||||
|
if reservation.board_service_room_id
|
||||||
|
else "",
|
||||||
|
checkinsRatio=reservation.checkins_ratio,
|
||||||
|
outstanding=reservation.folio_id.pending_amount,
|
||||||
pwaActionButtons=json.loads(reservation.pwa_action_buttons)
|
pwaActionButtons=json.loads(reservation.pwa_action_buttons)
|
||||||
if reservation.pwa_action_buttons
|
if reservation.pwa_action_buttons
|
||||||
else {},
|
else {},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@restapi.method(
|
||||||
|
[
|
||||||
|
(
|
||||||
|
[
|
||||||
|
"/<int:id>/cancellation",
|
||||||
|
],
|
||||||
|
"POST",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
auth="public",
|
||||||
|
)
|
||||||
|
def cancel_reservation(self, reservation_id):
|
||||||
|
reservation = self.env["pms.reservation"].search([("id", "=", reservation_id)])
|
||||||
|
if not reservation:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
reservation.action_cancel()
|
||||||
|
|||||||
Reference in New Issue
Block a user