Skip to content

[16.0][FIX] pms: check room capacity when the room of a reservation changes - #442

Open
DarioLodeiros wants to merge 1 commit into
OCA:16.0from
commitsun:16.0-fix-pms-check-capacity-on-room-change
Open

[16.0][FIX] pms: check room capacity when the room of a reservation changes#442
DarioLodeiros wants to merge 1 commit into
OCA:16.0from
commitsun:16.0-fix-pms-check-capacity-on-room-change

Conversation

@DarioLodeiros

Copy link
Copy Markdown
Member

Problem

The room capacity check used to be a constraint on pms.reservation. It was
turned 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,
    split/join/swap wizard), and
  • changing preferred_room_id on the reservation, whose recompute of the room
    of 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) instead
of 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_check context key for massive or automated changes.

Tests

Four tests in test_pms_reservation_line.py: the room change is blocked both
by 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

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
DarioLodeiros force-pushed the 16.0-fix-pms-check-capacity-on-room-change branch from fe339b5 to 5d96971 Compare August 26, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants