mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] Set to_assign to False when preferred_room_id is manually set
This commit is contained in:
@@ -313,9 +313,9 @@ class PmsReservation(models.Model):
|
|||||||
)
|
)
|
||||||
to_assign = fields.Boolean(
|
to_assign = fields.Boolean(
|
||||||
string="To Assign",
|
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,
|
default=True,
|
||||||
tracking=True,
|
|
||||||
)
|
)
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
string="State",
|
string="State",
|
||||||
@@ -615,6 +615,12 @@ class PmsReservation(models.Model):
|
|||||||
|
|
||||||
@api.depends("preferred_room_id")
|
@api.depends("preferred_room_id")
|
||||||
def _compute_room_type_id(self):
|
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:
|
for reservation in self:
|
||||||
if reservation.preferred_room_id and not reservation.room_type_id:
|
if reservation.preferred_room_id and not reservation.room_type_id:
|
||||||
reservation.room_type_id = reservation.preferred_room_id.room_type_id.id
|
reservation.room_type_id = reservation.preferred_room_id.room_type_id.id
|
||||||
|
|||||||
@@ -173,6 +173,17 @@ class PmsReservationLine(models.Model):
|
|||||||
and not line.room_id
|
and not line.room_id
|
||||||
):
|
):
|
||||||
free_room_select = True if reservation.preferred_room_id else False
|
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
|
# we get the rooms available for the entire stay
|
||||||
rooms_available = self.env["pms.availability.plan"].rooms_available(
|
rooms_available = self.env["pms.availability.plan"].rooms_available(
|
||||||
checkin=line.reservation_id.checkin,
|
checkin=line.reservation_id.checkin,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
<field name="splitted" invisible="True" />
|
<field name="splitted" invisible="True" />
|
||||||
<field name="tax_ids" invisible="1" />
|
<field name="tax_ids" invisible="1" />
|
||||||
<field name="checkin_partner_count" invisible="1" />
|
<field name="checkin_partner_count" invisible="1" />
|
||||||
|
<field name="to_assign" invisible="1" />
|
||||||
<button
|
<button
|
||||||
name="confirm"
|
name="confirm"
|
||||||
string="Confirm"
|
string="Confirm"
|
||||||
@@ -22,6 +23,13 @@
|
|||||||
type="object"
|
type="object"
|
||||||
attrs="{'invisible':[('state','not in',('draft','cancelled'))]}"
|
attrs="{'invisible':[('state','not in',('draft','cancelled'))]}"
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
name="action_assign"
|
||||||
|
string="Confirm Assigned Room"
|
||||||
|
class="oe_highlight"
|
||||||
|
type="object"
|
||||||
|
attrs="{'invisible':['|',('preferred_room_id','=',False),('to_assign', '=', False)]}"
|
||||||
|
/>
|
||||||
<button
|
<button
|
||||||
name="action_cancel"
|
name="action_cancel"
|
||||||
string="Cancel Reservation"
|
string="Cancel Reservation"
|
||||||
|
|||||||
Reference in New Issue
Block a user