diff --git a/pms/demo/pms_folio.xml b/pms/demo/pms_folio.xml
index e0616ce24a..cc0329bb82 100644
--- a/pms/demo/pms_folio.xml
+++ b/pms/demo/pms_folio.xml
@@ -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',
})]"
/>
@@ -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.',
})]"
/>
diff --git a/pms/demo/pms_reservation.xml b/pms/demo/pms_reservation.xml
index acc6fece84..a81748c12b 100644
--- a/pms/demo/pms_reservation.xml
+++ b/pms/demo/pms_reservation.xml
@@ -11,7 +11,7 @@
Extra privacy for school field trip.
@@ -24,7 +24,7 @@
- Carpet replacement.
+ Carpet replacement.
@@ -36,7 +36,7 @@
- Carpet replacement.
+ Carpet replacement.
@@ -49,7 +49,7 @@
- Wall painting.
+ Wall painting.
diff --git a/pms/models/pms_folio.py b/pms/models/pms_folio.py
index 63f0213311..43d0f8caa8 100644
--- a/pms/models/pms_folio.py
+++ b/pms/models/pms_folio.py
@@ -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",
@@ -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",
diff --git a/pms/models/pms_reservation.py b/pms/models/pms_reservation.py
index 32bf0ca36f..8dfe492f6c 100644
--- a/pms/models/pms_reservation.py
+++ b/pms/models/pms_reservation.py
@@ -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(
@@ -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",
@@ -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:
@@ -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)
@@ -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'"
)
)
@@ -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'"
)
)
@@ -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()
diff --git a/pms/models/pms_room.py b/pms/models/pms_room.py
index 2823f00547..579bf73867 100644
--- a/pms/models/pms_room.py
+++ b/pms/models/pms_room.py
@@ -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",
@@ -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:
diff --git a/pms/models/pms_room_closure_reason.py b/pms/models/pms_room_closure_reason.py
index a1135c623a..3ecc2776c6 100644
--- a/pms/models/pms_room_closure_reason.py
+++ b/pms/models/pms_room_closure_reason.py
@@ -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",
diff --git a/pms/views/pms_folio_views.xml b/pms/views/pms_folio_views.xml
index 187b9bc281..f86109bdb8 100644
--- a/pms/views/pms_folio_views.xml
+++ b/pms/views/pms_folio_views.xml
@@ -235,7 +235,7 @@
diff --git a/pms/views/pms_reservation_views.xml b/pms/views/pms_reservation_views.xml
index 2f6dbb7923..2cdfda410c 100644
--- a/pms/views/pms_reservation_views.xml
+++ b/pms/views/pms_reservation_views.xml
@@ -283,7 +283,7 @@
@@ -379,8 +379,8 @@
attrs="{'invisible':[('reservation_type','in',('out'))]}"
/>