Skip to content

[IMP] pms: prevent delete/cancel of past out-of-service blocks#396

Merged
OCA-git-bot merged 2 commits into
OCA:16.0from
commitsun:16.0-add-pms-block-modify-past-out-service
May 11, 2026
Merged

[IMP] pms: prevent delete/cancel of past out-of-service blocks#396
OCA-git-bot merged 2 commits into
OCA:16.0from
commitsun:16.0-add-pms-block-modify-past-out-service

Conversation

@DarioLodeiros
Copy link
Copy Markdown
Member

Summary

Adds a per-property setting block_modify_past_out_service (off by default) that prevents deleting or cancelling out-of-service reservations once they contain past days.

When the flag is enabled on a property:

  • Reservation has past + future days: deleting or cancelling the whole reservation is rejected with a message suggesting to shorten the block to release today or future days.
  • Reservation is fully in the past: deleting or cancelling is rejected outright.
  • Reservation line level: removing a single past day of an out-of-service block is also rejected — otherwise users could bypass the reservation-level check by deleting past lines one by one.

The check covers all paths that destroy or cancel an out-of-service reservation: direct unlink, cascade from folio deletion, action_cancel, and pms.folio.action_cancel (which iterates and calls pms.reservation.action_cancel).

Spanish translations included.

Test plan

  • Enable block_modify_past_out_service on a property.
  • Create an out-of-service block fully in the past — try to delete it / cancel it → both rejected with the "already in the past" message.
  • Create an out-of-service block spanning past and future — try to delete / cancel → rejected with the "shorten the block" message; shortening (removing future lines) works; removing past lines fails.
  • Create an out-of-service block fully in the future → delete and cancel work normally.
  • Disable the flag → all the above operations are allowed.
  • A non-out reservation in the past is unaffected by the new check.

Add a per-property setting (block_modify_past_out_service) that prevents
deleting or cancelling out-of-service reservations once they have past
days. Two cases:

* If the block still has present/future days, the user is told to
  shorten the block instead of deleting/cancelling it.
* If the block is already fully in the past, the operation is rejected.

The same control is applied at reservation_line level to prevent
removing past days one by one (which would otherwise bypass the
reservation-level check).

Spanish translations are included.
Cover the six core behaviors:

* delete fully-past block raises with "already in the past"
* cancel block with past+future days raises with "shorten the block"
* unlink of a past reservation_line is rejected
* unlink of a future reservation_line shortens the block successfully
* with the flag disabled, past blocks remain deletable
* non-out-of-service reservations are not affected by the flag
@DarioLodeiros
Copy link
Copy Markdown
Member Author

/ocabot merge minor

@OCA-git-bot
Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-396-by-DarioLodeiros-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 1c695e8 into OCA:16.0 May 11, 2026
6 of 7 checks passed
@OCA-git-bot
Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at d145f55. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants