mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] pms-api-rest: add several fields reserv. line service
This commit is contained in:
committed by
Darío Lodeiros
parent
2a0d960184
commit
c3fc102f0e
@@ -14,7 +14,7 @@
|
||||
"auth_jwt_login",
|
||||
],
|
||||
"external_dependencies": {
|
||||
"python": ["jwt", "simplejson", "marshmallow"],
|
||||
"python": ["jwt", "simplejson", "marshmallow", "jose"],
|
||||
},
|
||||
"data": ["data/auth_jwt_validator.xml"],
|
||||
"installable": True,
|
||||
|
||||
@@ -10,3 +10,6 @@ class PmsCalendarInfo(Datamodel):
|
||||
roomId = fields.Integer(required=False, allow_none=True)
|
||||
partnerId = fields.Integer(required=False, allow_none=True)
|
||||
reservationId = fields.Integer(required=False, allow_none=True)
|
||||
isFirstDay = fields.Boolean(required=False, allow_none=True)
|
||||
isLastDay = fields.Boolean(required=False, allow_none=True)
|
||||
totalPrice = fields.Float(required=False, allow_none=True)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from odoo.addons.base_rest import restapi
|
||||
from odoo.addons.base_rest_datamodel.restapi import Datamodel
|
||||
@@ -23,7 +23,6 @@ class PmsCalendarService(Component):
|
||||
input_param=Datamodel("pms.calendar.search.param"),
|
||||
output_param=Datamodel("pms.calendar.info", is_list=True),
|
||||
auth="jwt_api_pms",
|
||||
|
||||
)
|
||||
def get_calendar(self, calendar_search_param):
|
||||
domain = list()
|
||||
@@ -49,6 +48,10 @@ class PmsCalendarService(Component):
|
||||
date=datetime.combine(line.date, datetime.min.time()).isoformat(),
|
||||
partnerId=line.reservation_id.partner_id.id,
|
||||
reservationId=line.reservation_id,
|
||||
isFirstDay=line.reservation_id.checkin == line.date,
|
||||
isLastDay=line.reservation_id.checkout
|
||||
== (line.date + timedelta(days=1)),
|
||||
totalPrice=line.reservation_id.price_total,
|
||||
)
|
||||
)
|
||||
return result_lines
|
||||
|
||||
@@ -21,7 +21,6 @@ class PmsPropertyComponent(Component):
|
||||
input_param=Datamodel("pms.property.search.param"),
|
||||
output_param=Datamodel("pms.property.info", is_list=True),
|
||||
auth="jwt_api_pms",
|
||||
|
||||
)
|
||||
def get_properties(self, property_search_param):
|
||||
domain = []
|
||||
@@ -58,7 +57,6 @@ class PmsPropertyComponent(Component):
|
||||
],
|
||||
output_param=Datamodel("pms.property.info"),
|
||||
auth="jwt_api_pms",
|
||||
|
||||
)
|
||||
def get_property(self, property_id):
|
||||
pms_property = (
|
||||
@@ -88,11 +86,12 @@ class PmsPropertyComponent(Component):
|
||||
],
|
||||
output_param=Datamodel("pms.account.journal.info", is_list=True),
|
||||
auth="jwt_api_pms",
|
||||
|
||||
)
|
||||
def get_method_payments_property(self, property_id):
|
||||
|
||||
pms_property = self.env["pms.property"].sudo().search([("id", "=", property_id)])
|
||||
pms_property = (
|
||||
self.env["pms.property"].sudo().search([("id", "=", property_id)])
|
||||
)
|
||||
PmsAccountJournalInfo = self.env.datamodels["pms.account.journal.info"]
|
||||
res = []
|
||||
if not pms_property:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from odoo.addons.base_rest import restapi
|
||||
from odoo.addons.base_rest_datamodel.restapi import Datamodel
|
||||
@@ -22,7 +22,6 @@ class PmsRoomService(Component):
|
||||
],
|
||||
output_param=Datamodel("pms.reservation.info", is_list=True),
|
||||
auth="jwt_api_pms",
|
||||
|
||||
)
|
||||
def get_reservations(self):
|
||||
domain = []
|
||||
@@ -57,7 +56,6 @@ class PmsRoomService(Component):
|
||||
],
|
||||
input_param=Datamodel("pms.calendar.changes", is_list=False),
|
||||
auth="jwt_api_pms",
|
||||
|
||||
)
|
||||
def move_reservation_line(self, reservation_id, reservation_lines_changes):
|
||||
|
||||
@@ -96,3 +94,17 @@ class PmsRoomService(Component):
|
||||
and line_to_change.room_id.id != change_iterator["roomId"]
|
||||
):
|
||||
line_to_change.room_id = change_iterator["roomId"]
|
||||
|
||||
max_value = max(
|
||||
first_reservation_line_to_change.reservation_id.reservation_line_ids.mapped(
|
||||
"date"
|
||||
)
|
||||
) + timedelta(days=1)
|
||||
min_value = min(
|
||||
first_reservation_line_to_change.reservation_id.reservation_line_ids.mapped(
|
||||
"date"
|
||||
)
|
||||
)
|
||||
reservation = self.env["pms.reservation"].browse(reservation_id)
|
||||
reservation.checkin = min_value
|
||||
reservation.checkout = max_value
|
||||
|
||||
@@ -21,7 +21,6 @@ class PmsRoomService(Component):
|
||||
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 = []
|
||||
|
||||
@@ -21,7 +21,6 @@ class PmsRoomTypeService(Component):
|
||||
input_param=Datamodel("pms.room.search.param"),
|
||||
output_param=Datamodel("pms.room.info", is_list=True),
|
||||
auth="jwt_api_pms",
|
||||
|
||||
)
|
||||
def get_room_types(self, room_type_search_param):
|
||||
domain = []
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# generated from manifests external_dependencies
|
||||
bs4
|
||||
jose
|
||||
jwt
|
||||
marshmallow
|
||||
pycountry
|
||||
|
||||
Reference in New Issue
Block a user