mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: 1-Room assigned force real avail, 2-by assigned if not created by property team
This commit is contained in:
@@ -429,6 +429,7 @@ class PmsProperty(models.Model):
|
||||
room_type_id=False,
|
||||
current_lines=False,
|
||||
pricelist=False,
|
||||
real_avail=False,
|
||||
):
|
||||
if isinstance(checkin, str):
|
||||
checkin = datetime.datetime.strptime(
|
||||
@@ -449,6 +450,7 @@ class PmsProperty(models.Model):
|
||||
room_type_id=room_type_id,
|
||||
current_lines=current_lines,
|
||||
pricelist_id=pricelist.id,
|
||||
real_avail=real_avail,
|
||||
)
|
||||
|
||||
if len(pms_property.free_room_ids) < 1:
|
||||
|
||||
@@ -208,7 +208,7 @@ class PmsReservationLine(models.Model):
|
||||
else False,
|
||||
current_lines=reservation.reservation_line_ids.ids,
|
||||
pricelist_id=reservation.pricelist_id.id,
|
||||
real_avail=free_room_select,
|
||||
real_avail=False,
|
||||
)
|
||||
rooms_available = pms_property.free_room_ids
|
||||
|
||||
@@ -219,6 +219,7 @@ class PmsReservationLine(models.Model):
|
||||
free_room_select
|
||||
and reservation.preferred_room_id.id
|
||||
not in reservation.reservation_line_ids.room_id.ids
|
||||
and self.env.user._is_property_member(pms_property.id)
|
||||
):
|
||||
# This case is a preferred_room_id manually assigned
|
||||
manual_assigned = True
|
||||
@@ -264,6 +265,7 @@ class PmsReservationLine(models.Model):
|
||||
current_lines=line._origin.reservation_id.reservation_line_ids.ids,
|
||||
pricelist=reservation.pricelist_id,
|
||||
pms_property_id=line.pms_property_id.id,
|
||||
real_avail=False,
|
||||
):
|
||||
if self.env.context.get("force_overbooking"):
|
||||
reservation.overbooking = True
|
||||
|
||||
@@ -40,6 +40,14 @@ class ResUsers(models.Model):
|
||||
return self.env["pms.property"].browse(active_property_ids).ids
|
||||
return user_property_ids
|
||||
|
||||
def _is_property_member(self, pms_property_id):
|
||||
self.ensure_one()
|
||||
# TODO: Use pms_teams and roles to check if user is member of property
|
||||
# and analice the management of external users like a Call Center
|
||||
return self.env.user.has_group(
|
||||
"pms.group_pms_user"
|
||||
) and not self.env.user.has_group("pms.group_pms_call")
|
||||
|
||||
@api.constrains("pms_property_id", "pms_property_ids")
|
||||
def _check_property_in_allowed_properties(self):
|
||||
if any(user.pms_property_id not in user.pms_property_ids for user in self):
|
||||
|
||||
Reference in New Issue
Block a user