[16.0][FIX] pms: check room capacity when the room of a reservation changes - #442
Open
DarioLodeiros wants to merge 1 commit into
Open
[16.0][FIX] pms: check room capacity when the room of a reservation changes#442DarioLodeiros wants to merge 1 commit into
DarioLodeiros wants to merge 1 commit into
Conversation
The capacity check was turned from a constraint into a manual check called from create() and from write() only when 'adults' is in vals, to avoid false positives in intermediate states where the extra bed services of the vals are not accessible yet. As a side effect, no room change validates the capacity any more: writing room_id on the reservation lines (planning drag&drop, room swap) or changing the preferred room of the reservation (whose recompute of the room of the lines does not go through pms.reservation.line.write) allow to move a reservation to a room that cannot hold its guests. Check the capacity of the new room on both paths. To keep away from the false positives that motivated the manual check, the maximum capacity of the room (capacity + allowed extra beds) is used instead of the extra beds actually sold, and the check can be skipped with the 'avoid_capacity_check' context key for massive or automated changes.
DarioLodeiros
force-pushed
the
16.0-fix-pms-check-capacity-on-room-change
branch
from
August 26, 2026 08:36
fe339b5 to
5d96971
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The room capacity check used to be a constraint on
pms.reservation. It wasturned into a manual check called from
create()and fromwrite()only whenadultsis in vals, to avoid false positives in intermediate states where theextra bed services of the vals are not accessible yet.
As a side effect, no room change validates the capacity any more:
room_idon the reservation lines (planning drag&drop, room swap,split/join/swap wizard), and
preferred_room_idon the reservation, whose recompute of the roomof the lines does not go through
pms.reservation.line.write(),both allow moving a reservation to a room that cannot hold its guests (e.g. a
2 pax reservation into a single room), with the overoccupancy that follows.
Solution
Check the capacity of the new room on both paths, in a new
pms.reservation.line._check_room_capacity().To keep away from the false positives that motivated the manual check, it uses
the maximum capacity of the room (
capacity + extra_beds_allowed) insteadof the extra beds actually sold, so a room change is never blocked because the
extra bed service is not created yet. The check can be skipped with the
avoid_capacity_checkcontext key for massive or automated changes.Tests
Four tests in
test_pms_reservation_line.py: the room change is blocked bothby line and by preferred room, it is allowed when the destination room has an
allowed extra bed, and the context key skips it.
@commitsun
🤖 Generated with Claude Code