diff --git a/pms/models/pms_property.py b/pms/models/pms_property.py index a01e2535c..0e466347b 100644 --- a/pms/models/pms_property.py +++ b/pms/models/pms_property.py @@ -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: diff --git a/pms/models/pms_reservation_line.py b/pms/models/pms_reservation_line.py index c1be88987..d70e562ec 100644 --- a/pms/models/pms_reservation_line.py +++ b/pms/models/pms_reservation_line.py @@ -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 diff --git a/pms/models/res_users.py b/pms/models/res_users.py index a7becc480..e61736df5 100644 --- a/pms/models/res_users.py +++ b/pms/models/res_users.py @@ -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):