mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms_api_rest: added avail plan rule id to avail plan rule service and datamodele
This commit is contained in:
@@ -26,6 +26,7 @@ class PmsAvailabilityPlanRuleInfo(Datamodel):
|
||||
quota = fields.Integer(required=False, allow_none=True)
|
||||
maxAvailability = fields.Integer(required=False, allow_none=True)
|
||||
pmsPropertyId = fields.Integer(required=False, allow_none=True)
|
||||
availabilityPlanId = fields.Integer(required=False, allow_none=True)
|
||||
|
||||
|
||||
class PmsAvailabilityPlanRulesInfo(Datamodel):
|
||||
|
||||
@@ -20,6 +20,7 @@ class PmsPricelistItemInfo(Datamodel):
|
||||
pricelistId = fields.Integer(required=False, allow_none=True)
|
||||
pmsPropertyId = fields.Integer(required=False, allow_none=True)
|
||||
|
||||
|
||||
class PmsPricelistItemsInfo(Datamodel):
|
||||
_name = "pms.pricelist.items.info"
|
||||
pricelistItems = fields.List(NestedModel("pms.pricelist.item.info"))
|
||||
|
||||
@@ -158,34 +158,28 @@ class PmsAvailabilityPlanService(Component):
|
||||
):
|
||||
for avail_plan_rule in pms_avail_plan_rules_info.availabilityPlanRules:
|
||||
vals = dict()
|
||||
date = datetime.strptime(
|
||||
avail_plan_rule.date[:10], "%Y-%m-%d"
|
||||
) + timedelta(days=1)
|
||||
date = datetime.strptime(avail_plan_rule.date[:10], "%Y-%m-%d") + timedelta(
|
||||
days=1
|
||||
)
|
||||
if avail_plan_rule.minStay:
|
||||
vals.update({"min_stay": avail_plan_rule.minStay})
|
||||
if avail_plan_rule.minStayArrival:
|
||||
vals.update(
|
||||
{"min_stay_arrival": avail_plan_rule.minStayArrival}
|
||||
)
|
||||
vals.update({"min_stay_arrival": avail_plan_rule.minStayArrival})
|
||||
if avail_plan_rule.maxStay:
|
||||
vals.update({"max_stay": avail_plan_rule.maxStay})
|
||||
if avail_plan_rule.maxStayArrival:
|
||||
vals.update(
|
||||
{"max_stay_arrival": avail_plan_rule.maxStayArrival}
|
||||
)
|
||||
vals.update({"max_stay_arrival": avail_plan_rule.maxStayArrival})
|
||||
if avail_plan_rule.closed:
|
||||
vals.update({"closed": avail_plan_rule.closed})
|
||||
if avail_plan_rule.closedDeparture:
|
||||
vals.update(
|
||||
{"closed_departure": avail_plan_rule.closedDeparture}
|
||||
)
|
||||
vals.update({"closed_departure": avail_plan_rule.closedDeparture})
|
||||
if avail_plan_rule.closedArrival:
|
||||
vals.update({"closed_arrival": avail_plan_rule.closedArrival})
|
||||
if avail_plan_rule.quota:
|
||||
vals.update({"quota": avail_plan_rule.quota})
|
||||
avail_rule = self.env["pms.availability.plan.rule"].search(
|
||||
[
|
||||
("availability_plan_id", "=", availability_plan_id),
|
||||
("availability_plan_id", "=", avail_plan_rule.availabilityPlanId),
|
||||
("pms_property_id", "=", avail_plan_rule.pmsPropertyId),
|
||||
("room_type_id", "=", avail_plan_rule.roomTypeId),
|
||||
("date", "=", date),
|
||||
@@ -199,7 +193,7 @@ class PmsAvailabilityPlanService(Component):
|
||||
"room_type_id": avail_plan_rule.roomTypeId,
|
||||
"date": date,
|
||||
"pms_property_id": avail_plan_rule.pmsPropertyId,
|
||||
"availability_plan_id": availability_plan_id,
|
||||
"availability_plan_id": avail_plan_rule.availabilityPlanId,
|
||||
}
|
||||
)
|
||||
self.env["pms.availability.plan.rule"].create(vals)
|
||||
|
||||
@@ -166,11 +166,11 @@ class PmsPricelistService(Component):
|
||||
)
|
||||
product_pricelist_item = self.env["product.pricelist.item"].search(
|
||||
[
|
||||
("pricelist_id", "=", pricelist_id),
|
||||
("pricelist_id", "=", pms_pricelist_item.pricelistId),
|
||||
("product_id", "=", product_id.id),
|
||||
("pms_property_ids", "in", pms_pricelist_item.pmsPropertyId),
|
||||
("date_start_consumption", "=", date),
|
||||
("date_end_consumption", "=", date),
|
||||
("date_end_consumption", "=", date),
|
||||
]
|
||||
)
|
||||
if product_pricelist_item:
|
||||
@@ -189,6 +189,6 @@ class PmsPricelistService(Component):
|
||||
"date_end_consumption": date,
|
||||
"compute_price": "fixed",
|
||||
"fixed_price": pms_pricelist_item.price,
|
||||
"pricelist_id": pricelist_id,
|
||||
"pricelist_id": pms_pricelist_item.pricelistId,
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user