diff --git a/pms/models/pms_reservation.py b/pms/models/pms_reservation.py
index f62d4d13b..ce4f0a196 100644
--- a/pms/models/pms_reservation.py
+++ b/pms/models/pms_reservation.py
@@ -313,9 +313,9 @@ class PmsReservation(models.Model):
)
to_assign = fields.Boolean(
string="To Assign",
- help="Technical field",
+ help="It is True if the room of the reservation has been assigned "
+ "automatically, False if it was confirmed by a person in charge",
default=True,
- tracking=True,
)
state = fields.Selection(
string="State",
@@ -615,6 +615,12 @@ class PmsReservation(models.Model):
@api.depends("preferred_room_id")
def _compute_room_type_id(self):
+ """
+ This method set False to_assign when the user
+ directly chooses the preferred_room_id,
+ otherwise, action_assign will be used when the user manually confirms
+ or changes the preferred_room_id of the reservation
+ """
for reservation in self:
if reservation.preferred_room_id and not reservation.room_type_id:
reservation.room_type_id = reservation.preferred_room_id.room_type_id.id
diff --git a/pms/models/pms_reservation_line.py b/pms/models/pms_reservation_line.py
index 1719581e6..567198c50 100644
--- a/pms/models/pms_reservation_line.py
+++ b/pms/models/pms_reservation_line.py
@@ -173,6 +173,17 @@ class PmsReservationLine(models.Model):
and not line.room_id
):
free_room_select = True if reservation.preferred_room_id else False
+
+ # Check if the room assigment is manual or automatic to set the
+ # to_assign value on reservation
+ if (
+ free_room_select
+ and reservation.preferred_room_id.id
+ not in reservation.reservation_line_ids.room_id.ids
+ ):
+ # This case is a preferred_room_id manually assigned
+ reservation.to_assign = False
+
# we get the rooms available for the entire stay
rooms_available = self.env["pms.availability.plan"].rooms_available(
checkin=line.reservation_id.checkin,
diff --git a/pms/views/pms_reservation_views.xml b/pms/views/pms_reservation_views.xml
index c9599b969..6a7e18d52 100644
--- a/pms/views/pms_reservation_views.xml
+++ b/pms/views/pms_reservation_views.xml
@@ -15,6 +15,7 @@
+
+