mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD]pms: daily closed method
This commit is contained in:
@@ -490,3 +490,58 @@ class PmsProperty(models.Model):
|
||||
vals.update({"checkin_sequence_id": checkin_sequence.id})
|
||||
record = super(PmsProperty, self).create(vals)
|
||||
return record
|
||||
|
||||
@api.model
|
||||
def daily_closing(
|
||||
self, pms_property_ids, room_type_ids=False, availability_plan_ids=False
|
||||
):
|
||||
"""
|
||||
This method is used to close the daily availability of rooms
|
||||
"""
|
||||
pms_properties = self.browse(pms_property_ids)
|
||||
for pms_property in pms_properties:
|
||||
if not room_type_ids:
|
||||
room_type_ids = self.env["pms.room.type"].search(
|
||||
[
|
||||
"|",
|
||||
("pms_property_id", "=", pms_property.id),
|
||||
("pms_property_id", "=", False),
|
||||
]
|
||||
)
|
||||
if not availability_plan_ids:
|
||||
availability_plan_ids = self.env["pms.availability.plan"].search(
|
||||
[
|
||||
"|",
|
||||
("pms_property_id", "=", pms_property.id),
|
||||
("pms_property_id", "=", False),
|
||||
]
|
||||
)
|
||||
for room_type in self.env["pms.room.type"].browse(room_type_ids):
|
||||
for availability_plan in self.env["pms.availability.plan"].browse(
|
||||
availability_plan_ids
|
||||
):
|
||||
rule = self.env["pms.availability.plan.rule"].search(
|
||||
[
|
||||
("pms_property_id", "=", pms_property.id),
|
||||
("room_type_id", "=", room_type.id),
|
||||
("availability_plan_id", "=", availability_plan.id),
|
||||
]
|
||||
)
|
||||
if not rule:
|
||||
rule = self.env["pms.availability.plan.rule"].create(
|
||||
{
|
||||
"pms_property_id": pms_property.id,
|
||||
"room_type_id": room_type.id,
|
||||
"availability_plan_id": availability_plan.id,
|
||||
"date": fields.date.today(),
|
||||
"closed": True,
|
||||
}
|
||||
)
|
||||
elif not rule.closed:
|
||||
rule.write(
|
||||
{
|
||||
"closed": True,
|
||||
}
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
@@ -809,7 +809,7 @@ class AvailabilityWizard(models.TransientModel):
|
||||
overwrite = rules_to_overwrite.filtered(
|
||||
lambda x: x.room_type_id == room_type
|
||||
and x.date == date
|
||||
and x.pms_propert_id.id == pms_property.id
|
||||
and x.pms_property_id.id == pms_property.id
|
||||
)
|
||||
overwrite.write(vals)
|
||||
new_items += overwrite.ids
|
||||
|
||||
@@ -3,7 +3,6 @@ import datetime
|
||||
import io
|
||||
import json
|
||||
import time
|
||||
from datetime import date
|
||||
|
||||
import PyPDF2
|
||||
import requests
|
||||
@@ -71,13 +70,15 @@ class TravellerReport(models.TransientModel):
|
||||
"view_type": "form",
|
||||
}
|
||||
|
||||
def generate_checkin_list(self, property_id, date_target: date.today()):
|
||||
|
||||
def generate_checkin_list(self, property_id, date_target=False):
|
||||
if not date_target:
|
||||
date_target = fields.date.today()
|
||||
# check if there's guests info pending to send
|
||||
if self.env["pms.checkin.partner"].search_count(
|
||||
[
|
||||
("state", "=", "onboard"),
|
||||
("arrival", ">=", str(date_target) + " 0:00:00"),
|
||||
("pms_property_id", "=", property_id),
|
||||
]
|
||||
):
|
||||
pms_property = (
|
||||
@@ -91,6 +92,7 @@ class TravellerReport(models.TransientModel):
|
||||
("state", "=", "onboard"),
|
||||
("arrival", ">=", str(date_target) + " 0:00:00"),
|
||||
("arrival", "<=", str(date_target) + " 23:59:59"),
|
||||
("pms_property_id", "=", property_id),
|
||||
]
|
||||
)
|
||||
# build the property info record
|
||||
|
||||
Reference in New Issue
Block a user