Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pms/demo/pms_folio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<record id="pms_folio_4" model="pms.folio">
<field name="partner_id" ref="main_pms_property" />
<field name="user_id" ref="base.user_admin" />
<field name="reservation_type">out</field>
<field name="reservation_type">out_service</field>
<field name="pms_property_id" ref="pms.main_pms_property" />
<field
name="reservation_ids"
Expand All @@ -104,7 +104,7 @@
'checkout': (DateTime.today() + timedelta(days=17)),
'adults': 1,
'state': 'confirm',
'reservation_type': 'out',
'reservation_type': 'out_service',
'closure_reason_id': ref('pms_room_closure_reason_0'),
'out_service_description': 'Change of lighting',
})]"
Expand Down Expand Up @@ -225,7 +225,7 @@
<record id="pms_folio_8" model="pms.folio">
<field name="partner_id" ref="main_pms_property" />
<field name="user_id" ref="base.user_admin" />
<field name="reservation_type">out</field>
<field name="reservation_type">out_service</field>
<field name="pms_property_id" ref="pms.main_pms_property" />
<field
name="reservation_ids"
Expand All @@ -236,7 +236,7 @@
'checkout': (DateTime.today() + timedelta(days=20)),
'adults': 1,
'state': 'confirm',
'reservation_type': 'out',
'reservation_type': 'out_service',
'closure_reason_id': ref('pms_room_closure_reason_0'),
'out_service_description': 'Door arrangement',
})]"
Expand Down
2 changes: 1 addition & 1 deletion pms/demo/pms_reservation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<record id="pms_reservation_1" model="pms.reservation">
<field name="partner_id" ref="main_pms_property" />
<field name="user_id" ref="base.user_demo" />
<field name="reservation_type">"out"</field>
<field name="reservation_type">"out_service"</field>
<field name="room_type_id" ref="pms_room_type_0" />
<field name="checkin" eval="DateTime.today() + timedelta(-3)" />
<field name="checkout" eval="DateTime.today() + timedelta(-1)" />
Expand Down
8 changes: 6 additions & 2 deletions pms/models/pms_folio.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ class PmsFolio(models.Model):
help="The type of the reservation. "
"Can be 'Normal', 'Staff' or 'Out of Service'",
default=lambda *a: "normal",
selection=[("normal", "Normal"), ("staff", "Staff"), ("out", "Out of Service")],
selection=[
("normal", "Normal"),
("staff", "Staff"),
("out_service", "Out of Service"),
],
)
date_order = fields.Datetime(
string="Order Date",
Expand Down Expand Up @@ -795,7 +799,7 @@ def _compute_ratio_checkin_data(self):
)
def _compute_amount(self):
for record in self:
if record.reservation_type in ("staff", "out"):
if record.reservation_type in ("staff", "out_service"):
vals = {
"pending_amount": 0,
"invoices_paid": 0,
Expand Down
6 changes: 3 additions & 3 deletions pms/models/pms_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ class PmsReservation(models.Model):

def _compute_date_order(self):
for record in self:
record.date_order = datetime.datetime.today()
record.date_order = fields.Date.today()

# TODO:
# consider near_to_checkin & pending_notifications to order
Expand Down Expand Up @@ -676,7 +676,7 @@ def _compute_allowed_room_ids(self):
@api.depends("reservation_type", "agency_id", "folio_id")
def _compute_partner_id(self):
for reservation in self:
if reservation.reservation_type == "out":
if reservation.reservation_type == "out_service":
reservation.partner_id = reservation.pms_property_id.partner_id.id
elif not reservation.partner_id:
if reservation.folio_id:
Expand Down Expand Up @@ -1093,7 +1093,7 @@ def _compute_shared_folio(self):

def _compute_checkin_partner_count(self):
for record in self:
if record.reservation_type != "out":
if record.reservation_type != "out_service":
record.checkin_partner_count = len(record.checkin_partner_ids)
record.checkin_partner_pending_count = record.adults - len(
record.checkin_partner_ids
Expand Down
94 changes: 94 additions & 0 deletions pms/models/pms_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PmsRoom(models.Model):
default=lambda self: self.env.user.get_active_property_ids()[0],
comodel_name="pms.property",
ondelete="restrict",
check_pms_properties=True,
)
room_type_id = fields.Many2one(
string="Property Room Type",
Expand Down Expand Up @@ -77,6 +78,42 @@ class PmsRoom(models.Model):
" Order, Delivery Order and Customer Invoice/Credit Note",
translate=True,
)
occupation_status = fields.Selection(
string="Room Status",
selection=[
("occupied", "Occupied"),
("free", "Free"),
("out_service", "Out of service"),
],
help="Room status based on occupancy, next arrival, or out of service",
compute="_compute_occupation_status",
)
next_departure_reservation_id = fields.Many2one(
string="Currently reservation",
comodel_name="pms.reservation",
help="Reservation that currently occupies the room",
compute="_compute_occupation_status",
)
next_departure_datetime = fields.Datetime(
string="Next departure",
help="Expected departure from the reservation " "currently occupying the room",
compute="_compute_occupation_status",
)
next_arrival_reservation_id = fields.Many2one(
string="Next Reservation",
comodel_name="pms.reservation",
help="Next expected reservation",
compute="_compute_next_arrival",
)
next_arrival_datetime = fields.Datetime(
string="Next arrival",
help="Next expected arrival date",
compute="_compute_next_arrival",
)
color = fields.Integer(
string="Color Index",
default=1,
)

_sql_constraints = [
(
Expand All @@ -87,6 +124,63 @@ class PmsRoom(models.Model):
)
]

def _compute_occupation_status(self):
for record in self:
# Set Status and next departure fields
current_reservation = (
self.env["pms.reservation.line"]
.search(
[
("state", "in", ("onboard", "departure_delayed")),
("room_id", "=", record.id),
]
)
.reservation_id
)

record.occupation_status = "free"
record.next_departure_datetime = False
record.next_departure_reservation_id = False

if current_reservation:
record.occupation_status = "occupied"
record.next_departure_reservation_id = current_reservation
record.next_departure_datetime = current_reservation.checkout_datetime
if current_reservation.reservation_type == "out_service":
record.occupation_status = "out_service"

def _compute_next_arrival(self):
today = fields.Date.today()
for record in self:
future_reservation_dates = (
self.env["pms.reservation.line"]
.search(
[
("state", "in", ("draft", "confirm", "arrival_delayed")),
("room_id", "=", record.id),
("date", ">=", today),
]
)
.mapped("date")
)

record.next_arrival_reservation_id = (
self.env["pms.reservation.line"]
.search(
[
("room_id", "=", record.id),
("date", "=", min(future_reservation_dates)),
]
)
.reservation_id
)

record.next_arrival_datetime = (
record.next_arrival_reservation_id.checkin_datetime
if record.next_arrival_reservation_id
else False
)

def name_get(self):
result = []
for room in self:
Expand Down
4 changes: 2 additions & 2 deletions pms/views/pms_folio_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@
<field
name="partner_id"
placeholder="Guest"
attrs="{'invisible':[('reservation_type','in',('out'))]}"
attrs="{'invisible':[('reservation_type','in',('out_service'))]}"
/>
<field
name="closure_reason_id"
placeholder="Closure reason"
attrs="{'invisible':[('reservation_type','not in',('out'))]}"
attrs="{'invisible':[('reservation_type','not in',('out_service'))]}"
/>
</h1>
<group col="8">
Expand Down
24 changes: 12 additions & 12 deletions pms/views/pms_reservation_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@
name="partner_id"
default_focus="1"
placeholder="Lastname, Firstname"
attrs="{'invisible':[('reservation_type','in',('out'))]}"
attrs="{'invisible':[('reservation_type','in',('out_service'))]}"
required="1"
/>
<field
name="closure_reason_id"
default_focus="1"
options="{'no_create': True,'no_open': True}"
placeholder="Closure Reason"
attrs="{'invisible':[('reservation_type','not in',('out'))]}"
attrs="{'invisible':[('reservation_type','not in',('out_service'))]}"
/>
</h1>
<h3>
Expand Down Expand Up @@ -259,7 +259,7 @@
<field
name="out_service_description"
placeholder="Out service description"
attrs="{'invisible':[('reservation_type','not in',('out'))]}"
attrs="{'invisible':[('reservation_type','not in',('out_service'))]}"
/>
<group col="8">
<group
Expand All @@ -275,7 +275,7 @@
placeholder="email"
widget="email"
force_save="1"
attrs="{'invisible': [('reservation_type','in',('out'))],
attrs="{'invisible': [('reservation_type','in',('out_service'))],
'readonly': [('partner_id', '!=', False),
('partner_email','!=', False)]}"
/>
Expand All @@ -286,7 +286,7 @@
placeholder="mobile"
widget="phone"
force_save="1"
attrs="{'invisible': [('reservation_type','in',('out'))],
attrs="{'invisible': [('reservation_type','in',('out_service'))],
'readonly': [('partner_id', '!=', False),
('partner_mobile','!=', False)]}"
/>
Expand All @@ -296,7 +296,7 @@
nolabel="1"
name="partner_internal_comment"
string="Partner Note"
attrs="{'invisible': [('reservation_type','in',('out'))]}"
attrs="{'invisible': [('reservation_type','in',('out_service'))]}"
/>
<field name="nights" />
<field placeholder="Arrival Hour" name="arrival_hour" />
Expand All @@ -323,11 +323,11 @@
/>
<field
name="adults"
attrs="{'invisible': [('reservation_type','in',('out'))]}"
attrs="{'invisible': [('reservation_type','in',('out_service'))]}"
/>
<field
name="children"
attrs="{'invisible': [('reservation_type','in',('out'))]}"
attrs="{'invisible': [('reservation_type','in',('out_service'))]}"
/>
<field
name="children_occupying"
Expand All @@ -340,7 +340,7 @@
name="board_service_room_id"
domain="[('pms_room_type_id', '=', room_type_id)]"
options="{'no_create': True,'no_open': True}"
attrs="{'invisible': [('reservation_type','in',('out'))]}"
attrs="{'invisible': [('reservation_type','in',('out_service'))]}"
/>
<field
name="folio_internal_comment"
Expand Down Expand Up @@ -539,7 +539,7 @@
<page
name="persons"
string="Persons"
attrs="{'invisible': [('reservation_type','in',('out'))]}"
attrs="{'invisible': [('reservation_type','in',('out_service'))]}"
>
<group colspan="2" cols="6">
<field
Expand All @@ -561,7 +561,7 @@
<page
name="invoicing"
string="Invoicing"
attrs="{'invisible': [('reservation_type','in',('out'))]}"
attrs="{'invisible': [('reservation_type','in',('out_service'))]}"
>
</page>
<page name="others" string="Others">
Expand All @@ -575,7 +575,7 @@
<group>
<!--<field
name="channel_type"
attrs="{'required':[('reservation_type','not in',('staff','out'))]}"
attrs="{'required':[('reservation_type','not in',('staff','out_service'))]}"
/>-->
<field name="reservation_type" />
</group>
Expand Down
10 changes: 5 additions & 5 deletions pms_housekeeping/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"hr",
],
"data": [
# "wizard/housekeeping_rack.xml",
"views/pms_room_view.xml",
"views/pms_reservation_view.xml",
"views/pms_housekeeping_task_view.xml",
"views/pms_housekeeping_views.xml",
"views/pms_housekeeping_templates.xml",
"views/pms_reservation_views.xml",
"views/pms_housekeeping_task_type_views.xml",
"views/pms_housekeeping_task_views.xml",
"views/pms_room_views.xml",
"security/ir.model.access.csv",
"data/cron_jobs.xml",
],
Expand Down
Loading