mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]: added GET for res_users and is_board_service field in pms_service
This commit is contained in:
@@ -44,3 +44,4 @@ from . import pms_cancelation_rule
|
|||||||
from . import pms_agency
|
from . import pms_agency
|
||||||
from . import pms_service
|
from . import pms_service
|
||||||
from . import pms_service_line
|
from . import pms_service_line
|
||||||
|
from . import res_users
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class PmsReservationInfo(Datamodel):
|
|||||||
boardServiceId = fields.Integer(required=False, allow_none=True)
|
boardServiceId = fields.Integer(required=False, allow_none=True)
|
||||||
saleChannelId = fields.Integer(required=False, allow_none=True)
|
saleChannelId = fields.Integer(required=False, allow_none=True)
|
||||||
agencyId = fields.Integer(required=False, allow_none=True)
|
agencyId = fields.Integer(required=False, allow_none=True)
|
||||||
|
userId = fields.Integer(required=False, allow_none=True)
|
||||||
|
|
||||||
checkin = fields.String(required=False, allow_none=True)
|
checkin = fields.String(required=False, allow_none=True)
|
||||||
checkout = fields.String(required=False, allow_none=True)
|
checkout = fields.String(required=False, allow_none=True)
|
||||||
|
|||||||
@@ -12,3 +12,4 @@ class PmsServiceInfo(Datamodel):
|
|||||||
priceSubtotal = fields.Float(required=False, allow_none=True)
|
priceSubtotal = fields.Float(required=False, allow_none=True)
|
||||||
priceTaxes = fields.Float(required=False, allow_none=True)
|
priceTaxes = fields.Float(required=False, allow_none=True)
|
||||||
discount = fields.Float(required=False, allow_none=True)
|
discount = fields.Float(required=False, allow_none=True)
|
||||||
|
isBoardService = fields.Boolean(required=False, allow_none=True)
|
||||||
|
|||||||
9
pms_api_rest/datamodels/res_users.py
Normal file
9
pms_api_rest/datamodels/res_users.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from marshmallow import fields
|
||||||
|
|
||||||
|
from odoo.addons.datamodel.core import Datamodel
|
||||||
|
|
||||||
|
|
||||||
|
class PmsResUsersInfo(Datamodel):
|
||||||
|
_name = "res.users.info"
|
||||||
|
id = fields.Integer(required=False, allow_none=True)
|
||||||
|
name = fields.String(required=False, allow_none=True)
|
||||||
@@ -47,7 +47,7 @@ class PmsBoardServiceService(Component):
|
|||||||
name=line.pms_board_service_room_type_id.display_name,
|
name=line.pms_board_service_room_type_id.display_name,
|
||||||
boardServiceId=line.pms_board_service_room_type_id.id,
|
boardServiceId=line.pms_board_service_room_type_id.id,
|
||||||
productId=line.product_id.id,
|
productId=line.product_id.id,
|
||||||
amount=round(line.amount,2),
|
amount=round(line.amount, 2),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return result_board_service_lines
|
return result_board_service_lines
|
||||||
@@ -75,7 +75,7 @@ class PmsBoardServiceService(Component):
|
|||||||
name=board_service_line.pms_board_service_room_type_id.display_name,
|
name=board_service_line.pms_board_service_room_type_id.display_name,
|
||||||
boardServiceId=board_service_line.pms_board_service_room_type_id.id,
|
boardServiceId=board_service_line.pms_board_service_room_type_id.id,
|
||||||
productId=board_service_line.product_id.id,
|
productId=board_service_line.product_id.id,
|
||||||
amount=round(board_service_line.amount,2),
|
amount=round(board_service_line.amount, 2),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise MissingError(_("Board service line not found"))
|
raise MissingError(_("Board service line not found"))
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class PmsBoardServiceService(Component):
|
|||||||
id=board_service.id,
|
id=board_service.id,
|
||||||
name=board_service.pms_board_service_id.display_name,
|
name=board_service.pms_board_service_id.display_name,
|
||||||
roomTypeId=board_service.pms_room_type_id.id,
|
roomTypeId=board_service.pms_room_type_id.id,
|
||||||
amount=round(board_service.amount,2),
|
amount=round(board_service.amount, 2),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return result_board_services
|
return result_board_services
|
||||||
@@ -127,7 +127,7 @@ class PmsBoardServiceService(Component):
|
|||||||
name=line.pms_board_service_room_type_id.display_name,
|
name=line.pms_board_service_room_type_id.display_name,
|
||||||
boardServiceId=line.pms_board_service_room_type_id.id,
|
boardServiceId=line.pms_board_service_room_type_id.id,
|
||||||
productId=line.product_id.id,
|
productId=line.product_id.id,
|
||||||
amount=round(line.amount,2),
|
amount=round(line.amount, 2),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return result_board_service_lines
|
return result_board_service_lines
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ class PmsCalendarService(Component):
|
|||||||
isFirstNight=line.reservation_id.checkin == line.date,
|
isFirstNight=line.reservation_id.checkin == line.date,
|
||||||
isLastNight=line.reservation_id.checkout + timedelta(days=-1)
|
isLastNight=line.reservation_id.checkout + timedelta(days=-1)
|
||||||
== line.date,
|
== line.date,
|
||||||
totalPrice=round(line.reservation_id.price_total,2),
|
totalPrice=round(line.reservation_id.price_total, 2),
|
||||||
pendingPayment=round(line.reservation_id.folio_pending_amount,2),
|
pendingPayment=round(line.reservation_id.folio_pending_amount, 2),
|
||||||
numNotifications=line.reservation_id.message_needaction_counter,
|
numNotifications=line.reservation_id.message_needaction_counter,
|
||||||
adults=line.reservation_id.adults,
|
adults=line.reservation_id.adults,
|
||||||
nextLineSplitted=next_line_splitted,
|
nextLineSplitted=next_line_splitted,
|
||||||
@@ -176,8 +176,11 @@ class PmsCalendarService(Component):
|
|||||||
result.append(
|
result.append(
|
||||||
PmsCalendarDailyInvoicing(
|
PmsCalendarDailyInvoicing(
|
||||||
date=datetime.combine(day, datetime.min.time()).isoformat(),
|
date=datetime.combine(day, datetime.min.time()).isoformat(),
|
||||||
invoicingTotal=round(sum(reservation_lines_by_day.mapped("price"))
|
invoicingTotal=round(
|
||||||
+ sum(service_lines_by_day.mapped("price_day_total")),2)
|
sum(reservation_lines_by_day.mapped("price"))
|
||||||
|
+ sum(service_lines_by_day.mapped("price_day_total")),
|
||||||
|
2,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class PmsFolioService(Component):
|
|||||||
state=dict(folio.fields_get(["state"])["state"]["selection"])[
|
state=dict(folio.fields_get(["state"])["state"]["selection"])[
|
||||||
folio.state
|
folio.state
|
||||||
],
|
],
|
||||||
amountTotal=round(folio.amount_total,2),
|
amountTotal=round(folio.amount_total, 2),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise MissingError(_("Folio not found"))
|
raise MissingError(_("Folio not found"))
|
||||||
@@ -148,7 +148,7 @@ class PmsFolioService(Component):
|
|||||||
partnerName=folio.partner_name if folio.partner_name else None,
|
partnerName=folio.partner_name if folio.partner_name else None,
|
||||||
partnerPhone=folio.mobile if folio.mobile else None,
|
partnerPhone=folio.mobile if folio.mobile else None,
|
||||||
partnerEmail=folio.email if folio.email else None,
|
partnerEmail=folio.email if folio.email else None,
|
||||||
amountTotal=round(folio.amount_total,2),
|
amountTotal=round(folio.amount_total, 2),
|
||||||
reservations=[] if not reservations else reservations,
|
reservations=[] if not reservations else reservations,
|
||||||
paymentStateCode=folio.payment_state,
|
paymentStateCode=folio.payment_state,
|
||||||
paymentStateDescription=dict(
|
paymentStateDescription=dict(
|
||||||
@@ -193,7 +193,7 @@ class PmsFolioService(Component):
|
|||||||
payments.append(
|
payments.append(
|
||||||
PmsPaymentInfo(
|
PmsPaymentInfo(
|
||||||
id=payment.id,
|
id=payment.id,
|
||||||
amount=round(payment.amount,2),
|
amount=round(payment.amount, 2),
|
||||||
journalId=payment.journal_id.id,
|
journalId=payment.journal_id.id,
|
||||||
date=datetime.combine(
|
date=datetime.combine(
|
||||||
payment.date, datetime.min.time()
|
payment.date, datetime.min.time()
|
||||||
@@ -206,7 +206,7 @@ class PmsFolioService(Component):
|
|||||||
payments.append(
|
payments.append(
|
||||||
PmsPaymentInfo(
|
PmsPaymentInfo(
|
||||||
id=payment.id,
|
id=payment.id,
|
||||||
amount=round(payment.amount,2),
|
amount=round(payment.amount, 2),
|
||||||
journalId=payment.journal_id.id,
|
journalId=payment.journal_id.id,
|
||||||
date=datetime.combine(
|
date=datetime.combine(
|
||||||
payment.date, datetime.min.time()
|
payment.date, datetime.min.time()
|
||||||
@@ -265,13 +265,11 @@ class PmsFolioService(Component):
|
|||||||
readyForCheckin=reservation.ready_for_checkin,
|
readyForCheckin=reservation.ready_for_checkin,
|
||||||
allowedCheckout=reservation.allowed_checkout,
|
allowedCheckout=reservation.allowed_checkout,
|
||||||
splitted=reservation.splitted,
|
splitted=reservation.splitted,
|
||||||
priceTotal=round(reservation.price_room_services_set,2),
|
priceTotal=round(reservation.price_room_services_set, 2),
|
||||||
servicesCount=sum(
|
servicesCount=sum(
|
||||||
reservation.service_ids.filtered(
|
reservation.service_ids.filtered(
|
||||||
|
|
||||||
lambda x: not x.is_board_service
|
lambda x: not x.is_board_service
|
||||||
)
|
).mapped("product_qty")
|
||||||
.mapped("product_qty")
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ class PmsPricelistService(Component):
|
|||||||
if pricelist.cancelation_rule_id
|
if pricelist.cancelation_rule_id
|
||||||
else None,
|
else None,
|
||||||
defaultAvailabilityPlanId=pricelist.availability_plan_id.id
|
defaultAvailabilityPlanId=pricelist.availability_plan_id.id
|
||||||
if pricelist.availability_plan_id else None
|
if pricelist.availability_plan_id
|
||||||
,
|
else None,
|
||||||
pmsPropertyIds=pricelist.pms_property_ids.mapped("id"),
|
pmsPropertyIds=pricelist.pms_property_ids.mapped("id"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ class PmsProductService(Component):
|
|||||||
PmsProductInfo(
|
PmsProductInfo(
|
||||||
id=product.id,
|
id=product.id,
|
||||||
name=product.name,
|
name=product.name,
|
||||||
price=round(self._get_product_price(product, product_search_param),2),
|
price=round(
|
||||||
|
self._get_product_price(product, product_search_param), 2
|
||||||
|
),
|
||||||
perDay=product.per_day,
|
perDay=product.per_day,
|
||||||
perPerson=product.per_person,
|
perPerson=product.per_person,
|
||||||
)
|
)
|
||||||
@@ -79,7 +81,7 @@ class PmsProductService(Component):
|
|||||||
return PmsProductInfo(
|
return PmsProductInfo(
|
||||||
id=product.id,
|
id=product.id,
|
||||||
name=product.name,
|
name=product.name,
|
||||||
price=round(self._get_product_price(product, product_search_param),2),
|
price=round(self._get_product_price(product, product_search_param), 2),
|
||||||
perDay=product.per_day,
|
perDay=product.per_day,
|
||||||
perPerson=product.per_person,
|
perPerson=product.per_person,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -120,3 +120,25 @@ class PmsPropertyService(Component):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@restapi.method(
|
||||||
|
[
|
||||||
|
(
|
||||||
|
[
|
||||||
|
"/<int:property_id>/users",
|
||||||
|
],
|
||||||
|
"GET",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
output_param=Datamodel("res.users.info", is_list=True),
|
||||||
|
auth="jwt_api_pms",
|
||||||
|
)
|
||||||
|
def get_users(self, pms_property_id):
|
||||||
|
result_users = []
|
||||||
|
ResUsersInfo = self.env.datamodels["res.users.info"]
|
||||||
|
users = self.env["res.users"].search(
|
||||||
|
[("pms_property_id", "=", pms_property_id)]
|
||||||
|
)
|
||||||
|
for user in users:
|
||||||
|
result_users.append(ResUsersInfo(id=user.id, name=user.name))
|
||||||
|
return result_users
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ class PmsReservationLineService(Component):
|
|||||||
date=datetime.combine(
|
date=datetime.combine(
|
||||||
reservation_line.date, datetime.min.time()
|
reservation_line.date, datetime.min.time()
|
||||||
).isoformat(),
|
).isoformat(),
|
||||||
price=round(reservation_line.price,2),
|
price=round(reservation_line.price, 2),
|
||||||
discount=round(reservation_line.discount,2),
|
discount=round(reservation_line.discount, 2),
|
||||||
cancelDiscount=round(reservation_line.cancel_discount,2),
|
cancelDiscount=round(reservation_line.cancel_discount, 2),
|
||||||
roomId=reservation_line.room_id.id,
|
roomId=reservation_line.room_id.id,
|
||||||
reservationId=reservation_line.reservation_id.id,
|
reservationId=reservation_line.reservation_id.id,
|
||||||
pmsPropertyId=reservation_line.pms_property_id.id,
|
pmsPropertyId=reservation_line.pms_property_id.id,
|
||||||
@@ -90,9 +90,9 @@ class PmsReservationLineService(Component):
|
|||||||
date=datetime.combine(
|
date=datetime.combine(
|
||||||
reservation_line.date, datetime.min.time()
|
reservation_line.date, datetime.min.time()
|
||||||
).isoformat(),
|
).isoformat(),
|
||||||
price=round(reservation_line.price,2),
|
price=round(reservation_line.price, 2),
|
||||||
discount=round(reservation_line.discount,2),
|
discount=round(reservation_line.discount, 2),
|
||||||
cancelDiscount=round(reservation_line.cancel_discount,2),
|
cancelDiscount=round(reservation_line.cancel_discount, 2),
|
||||||
roomId=reservation_line.room_id.id,
|
roomId=reservation_line.room_id.id,
|
||||||
reservationId=reservation_line.reservation_id.id,
|
reservationId=reservation_line.reservation_id.id,
|
||||||
pmsPropertyId=reservation_line.pms_property_id.id,
|
pmsPropertyId=reservation_line.pms_property_id.id,
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ class PmsReservationService(Component):
|
|||||||
if reservation.channel_type_id
|
if reservation.channel_type_id
|
||||||
else None,
|
else None,
|
||||||
agencyId=reservation.agency_id.id if reservation.agency_id else None,
|
agencyId=reservation.agency_id.id if reservation.agency_id else None,
|
||||||
|
userId=reservation.user_id.id,
|
||||||
checkin=datetime.combine(
|
checkin=datetime.combine(
|
||||||
reservation.checkin, datetime.min.time()
|
reservation.checkin, datetime.min.time()
|
||||||
).isoformat(),
|
).isoformat(),
|
||||||
@@ -103,13 +104,13 @@ class PmsReservationService(Component):
|
|||||||
else None,
|
else None,
|
||||||
toAssign=reservation.to_assign,
|
toAssign=reservation.to_assign,
|
||||||
reservationType=reservation.reservation_type,
|
reservationType=reservation.reservation_type,
|
||||||
priceTotal=round(reservation.price_room_services_set,2),
|
priceTotal=round(reservation.price_room_services_set, 2),
|
||||||
discount=round(reservation.discount,2),
|
discount=round(reservation.discount, 2),
|
||||||
commissionAmount=round(reservation.commission_amount, 2)
|
commissionAmount=round(reservation.commission_amount, 2)
|
||||||
if reservation.commission_amount
|
if reservation.commission_amount
|
||||||
else None,
|
else None,
|
||||||
priceOnlyServices=round(reservation.price_services,2),
|
priceOnlyServices=round(reservation.price_services, 2),
|
||||||
priceOnlyRoom=round(reservation.price_total,2),
|
priceOnlyRoom=round(reservation.price_total, 2),
|
||||||
)
|
)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@@ -239,9 +240,9 @@ class PmsReservationService(Component):
|
|||||||
date=datetime.combine(
|
date=datetime.combine(
|
||||||
reservation_line.date, datetime.min.time()
|
reservation_line.date, datetime.min.time()
|
||||||
).isoformat(),
|
).isoformat(),
|
||||||
price=round(reservation_line.price,2),
|
price=round(reservation_line.price, 2),
|
||||||
discount=round(reservation_line.discount,2),
|
discount=round(reservation_line.discount, 2),
|
||||||
cancelDiscount=round(reservation_line.cancel_discount,2),
|
cancelDiscount=round(reservation_line.cancel_discount, 2),
|
||||||
roomId=reservation_line.room_id.id,
|
roomId=reservation_line.room_id.id,
|
||||||
reservationId=reservation_line.reservation_id.id,
|
reservationId=reservation_line.reservation_id.id,
|
||||||
pmsPropertyId=reservation_line.pms_property_id.id,
|
pmsPropertyId=reservation_line.pms_property_id.id,
|
||||||
@@ -273,10 +274,11 @@ class PmsReservationService(Component):
|
|||||||
id=service.id,
|
id=service.id,
|
||||||
name=service.name,
|
name=service.name,
|
||||||
quantity=service.product_qty,
|
quantity=service.product_qty,
|
||||||
priceTotal=round(service.price_total,2),
|
priceTotal=round(service.price_total, 2),
|
||||||
priceSubtotal=round(service.price_subtotal,2),
|
priceSubtotal=round(service.price_subtotal, 2),
|
||||||
priceTaxes=round(service.price_tax,2),
|
priceTaxes=round(service.price_tax, 2),
|
||||||
discount=round(service.discount,2),
|
discount=round(service.discount, 2),
|
||||||
|
isBoardService=service.is_board_service,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return result_services
|
return result_services
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class PmsRoomTypeService(Component):
|
|||||||
name=room.name,
|
name=room.name,
|
||||||
pmsPropertyIds=room.pms_property_ids.mapped("id"),
|
pmsPropertyIds=room.pms_property_ids.mapped("id"),
|
||||||
defaultCode=room.default_code,
|
defaultCode=room.default_code,
|
||||||
price=round(room.list_price,2),
|
price=round(room.list_price, 2),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return result_rooms
|
return result_rooms
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ class PmsServiceService(Component):
|
|||||||
date=datetime.combine(
|
date=datetime.combine(
|
||||||
service_line.date, datetime.min.time()
|
service_line.date, datetime.min.time()
|
||||||
).isoformat(),
|
).isoformat(),
|
||||||
priceUnit=round(service_line.price_unit,2),
|
priceUnit=round(service_line.price_unit, 2),
|
||||||
priceTotal=round(service_line.price_day_total,2),
|
priceTotal=round(service_line.price_day_total, 2),
|
||||||
discount=round(service_line.discount,2),
|
discount=round(service_line.discount, 2),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return result_service_lines
|
return result_service_lines
|
||||||
|
|||||||
Reference in New Issue
Block a user