Skip to content

Commit

Permalink
[IMP] pms: add necessary fields in room for housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
saralb9 committed Jan 31, 2024
1 parent 816c464 commit 877a0da
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 27 deletions.
4 changes: 2 additions & 2 deletions pms/demo/pms_folio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
'state': 'confirm',
'reservation_type': 'out',
'closure_reason_id': ref('pms_room_closure_reason_maintenance'),
'out_service_description': 'Change of lighting',
'out_order_description': 'Change of lighting',
})]"
/>
</record>
Expand Down Expand Up @@ -407,7 +407,7 @@
'state': 'confirm',
'reservation_type': 'out',
'closure_reason_id': ref('pms_room_closure_reason_vip_privacy'),
'out_service_description': 'Room next to noisy guests.',
'out_order_description': 'Room next to noisy guests.',
})]"
/>
</record>
Expand Down
8 changes: 4 additions & 4 deletions pms/demo/pms_reservation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<field name="checkout" eval="DateTime.today()" />
<field name="closure_reason_id" ref="pms_room_closure_reason_vip_privacy" />
<field
name="out_service_description"
name="out_order_description"
>Extra privacy for school field trip.</field>
<field name="pms_property_id" ref="pms.main_pms_property" />
<field name="sale_channel_origin_id" ref="pms.main_pms_sale_channel_mail" />
Expand All @@ -24,7 +24,7 @@
<field name="checkin" eval="DateTime.today() + timedelta(-3)" />
<field name="checkout" eval="DateTime.today() + timedelta(1)" />
<field name="closure_reason_id" ref="pms_room_closure_reason_maintenance" />
<field name="out_service_description">Carpet replacement.</field>
<field name="out_order_description">Carpet replacement.</field>
<field name="pms_property_id" ref="pms.main_pms_property" />
<field name="sale_channel_origin_id" ref="pms.main_pms_sale_channel_mail" />
</record>
Expand All @@ -36,7 +36,7 @@
<field name="checkin" eval="DateTime.today() + timedelta(-1)" />
<field name="checkout" eval="DateTime.today() + timedelta(1)" />
<field name="closure_reason_id" ref="pms_room_closure_reason_maintenance" />
<field name="out_service_description">Carpet replacement.</field>
<field name="out_order_description">Carpet replacement.</field>
<field name="pms_property_id" ref="pms.main_pms_property" />
<field name="sale_channel_origin_id" ref="pms.main_pms_sale_channel_mail" />
</record>
Expand All @@ -49,7 +49,7 @@
<field name="checkin" eval="DateTime.today() + timedelta(2)" />
<field name="checkout" eval="DateTime.today() + timedelta(7)" />
<field name="closure_reason_id" ref="pms_room_closure_reason_maintenance" />
<field name="out_service_description">Wall painting.</field>
<field name="out_order_description">Wall painting.</field>
<field name="pms_property_id" ref="pms.main_pms_property" />
<field name="sale_channel_origin_id" ref="pms.main_pms_sale_channel_mail" />
</record>
Expand Down
10 changes: 5 additions & 5 deletions pms/models/pms_folio.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ class PmsFolio(models.Model):
index=True,
check_pms_properties=True,
)
out_service_description = fields.Text(
string="Cause of out of service",
help="Indicates the cause of out of service",
out_order_description = fields.Text(
string="Cause of out of order",
help="Indicates the cause of out of order",
)
segmentation_ids = fields.Many2many(
string="Segmentation",
Expand All @@ -360,9 +360,9 @@ class PmsFolio(models.Model):
reservation_type = fields.Selection(
string="Type",
help="The type of the reservation. "
"Can be 'Normal', 'Staff' or 'Out of Service'",
"Can be 'Normal', 'Staff' or 'Out of Order'",
default=lambda *a: "normal",
selection=[("normal", "Normal"), ("staff", "Staff"), ("out", "Out of Service")],
selection=[("normal", "Normal"), ("staff", "Staff"), ("out", "Out of Order")],
)
date_order = fields.Datetime(
string="Order Date",
Expand Down
20 changes: 11 additions & 9 deletions pms/models/pms_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ class PmsReservation(models.Model):
check_pms_properties=True,
readonly=False,
)
out_service_description = fields.Text(
string="Cause of out of service",
help="Indicates the cause of out of service",
related="folio_id.out_service_description",
out_order_description = fields.Text(
string="Cause of out of order",
help="Indicates the cause of out of order",
related="folio_id.out_order_description",
readonly=False,
)
company_id = fields.Many2one(
Expand Down Expand Up @@ -399,11 +399,11 @@ class PmsReservation(models.Model):
)
reservation_type = fields.Selection(
string="Reservation Type",
help="Type of reservations. It can be 'normal', 'staff' or 'out of service",
help="Type of reservations. It can be 'normal', 'staff' or 'out of order",
store=True,
readonly=False,
compute="_compute_reservation_type",
selection=[("normal", "Normal"), ("staff", "Staff"), ("out", "Out of Service")],
selection=[("normal", "Normal"), ("staff", "Staff"), ("out", "Out of Order")],
)
splitted = fields.Boolean(
string="Splitted",
Expand Down Expand Up @@ -1477,7 +1477,7 @@ def _compute_shared_folio(self):
"partner_id.name",
"agency_id",
"reservation_type",
"out_service_description",
"out_order_description",
)
def _compute_partner_name(self):
for record in self:
Expand Down Expand Up @@ -1849,6 +1849,7 @@ def _check_onboard_reservation(self):
not record.checkin_partner_ids.filtered(lambda c: c.state == "onboard")
and record.state == "onboard"
and record.reservation_type != "out"
and record.preferred_room_id.state == "ready"
):
raise ValidationError(
_("No person from reserve %s has arrived", record.name)
Expand Down Expand Up @@ -1895,7 +1896,7 @@ def _check_closure_reason_id(self):
raise ValidationError(
_(
"A closure reason is mandatory when reservation"
" type is 'out of service'"
" type is 'out of order'"
)
)

Expand Down Expand Up @@ -2181,7 +2182,7 @@ def _check_clousure_reason(self, reservation_type, closure_reason_id):
raise ValidationError(
_(
"A closure reason is mandatory when reservation"
" type is 'out of service'"
" type is 'out of order'"
)
)

Expand Down Expand Up @@ -2486,6 +2487,7 @@ def auto_departure_delayed(self):
reservation.autocheckout(reservation)
else:
reservation.state = "done"
reservation.preferred_room_id.room_state = "not_ready"

def preview_reservation(self):
self.ensure_one()
Expand Down
39 changes: 39 additions & 0 deletions pms/models/pms_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,32 @@ class PmsRoom(models.Model):
"the room name and two incremental numbers",
)

room_state = fields.Selection(
string="Room State",
help="Room status at a specific time. It can be 'ready' or 'not ready'",
store=True,
readonly=False,
selection=[("ready", "Ready"), ("not_ready", "Not Ready")],
default="ready",
)

out_of_service = fields.Boolean(
string="Out of service",
help="True if room has any incidence, false if the room is ok",
)

out_of_service_reason = fields.Text(
string="Cause of out of service",
help="Description of why the room is out of order",
)

out_of_order = fields.Boolean(
string="Out of order",
help="True if room is not for sale, false if the room is for sale",
store=False,
compute="_compute_out_of_order",
)

_sql_constraints = [
(
"room_property_unique",
Expand All @@ -134,6 +160,19 @@ def _compute_is_shared_room(self):
elif not record.is_shared_room:
record.is_shared_room = False

# @api.depends("reservation_line_ids")
def _compute_out_of_order(self):
for record in self:
today = fields.Date.today()
reservation_lines = self.env["pms.reservation.line"].search(
[
("room_id", "=", record.id),
("date", "=", today),
("reservation_id.reservation_type", "=", "out"),
]
)
record.out_of_order = bool(reservation_lines)

def name_get(self):
result = []
for room in self:
Expand Down
2 changes: 1 addition & 1 deletion pms/models/pms_room_closure_reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class RoomClosureReason(models.Model):
_name = "room.closure.reason"
_description = "Cause of out of service"
_description = "Cause of out of order"

name = fields.Char(
string="Name",
Expand Down
2 changes: 1 addition & 1 deletion pms/views/pms_folio_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@

<widget
name="web_ribbon"
title="Out of Service"
title="Out of Order"
bg_color="bg-dark"
attrs="{'invisible': [('reservation_type', 'not in', 'out')]}"
/>
Expand Down
10 changes: 5 additions & 5 deletions pms/views/pms_reservation_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@

<widget
name="web_ribbon"
title="Out of Service"
title="Out of Order"
bg_color="bg-dark"
attrs="{'invisible': [('reservation_type', 'not in', 'out')]}"
/>
Expand Down Expand Up @@ -379,8 +379,8 @@
attrs="{'invisible':[('reservation_type','in',('out'))]}"
/>
<field
name="out_service_description"
placeholder="Out service description"
name="out_order_description"
placeholder="Out order description"
attrs="{'invisible':[('reservation_type','not in',('out'))]}"
/>
<field
Expand Down Expand Up @@ -1051,8 +1051,8 @@
domain="[('reservation_type','in',['staff'])]"
/>
<filter
string="Out of Service"
name="out_of_service"
string="Out of Order"
name="out_of_order"
domain="[('reservation_type','in',['out'])]"
/>
<group expand="0" string="Group By">
Expand Down

0 comments on commit 877a0da

Please sign in to comment.