[IMP] Set to_assign to False when preferred_room_id is manually set

This commit is contained in:
Dario Lodeiros
2021-06-13 11:28:58 +02:00
parent 0892c57f9d
commit 7ddc341d8e
3 changed files with 27 additions and 2 deletions

View File

@@ -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