Skip to content

[IMP] resource_booking: per-resource booking buffer (post-booking cooldown)#4

Open
dnplkndll wants to merge 1 commit into
18.0from
18.0-imp-resource_booking-booking_buffer
Open

[IMP] resource_booking: per-resource booking buffer (post-booking cooldown)#4
dnplkndll wants to merge 1 commit into
18.0from
18.0-imp-resource_booking-booking_buffer

Conversation

@dnplkndll
Copy link
Copy Markdown

Summary

Adds a Float field booking_buffer (hours, SQL-constrained nonnegative, default 0) on resource.resource. When non-zero, the resource is treated as busy for that many hours after each scheduled booking ends, so the next slot cannot start within the cooldown window.

Wires it into _get_intervals via a new _get_buffered_booking_intervals helper that scans recently-ending overlapping bookings sharing at least one buffered resource, then subtracts the cooldown windows from the candidate availability. Default 0 preserves the existing back-to-back slot behavior.

Useful for resources that need cleanup/reset/turnaround time between appointments (rooms, equipment, etc.) without inflating the booking duration itself.

Test plan

  • CI green
  • Runboat build comes up
  • Manual: set booking_buffer = 1.0 on a resource, create a 30-min booking ending at 09:00, verify portal cannot offer 09:30 but can offer 10:00

Provenance

Surgical extraction from Brenden Eshbach's (Techsystech) work on the website_appointment_booking PR fork: see review branch 18.0-techsystech-review-resource_booking for the original combined diff.

@dnplkndll
Copy link
Copy Markdown
Author

Followup notes from the Techsystech review

These two cleanups are not part of this PR but were flagged during the review of Brenden Eshbach's (Techsystech) branch that this PR was extracted from. Recording here so they don't get lost.

Followup A — portal helpers hardcode US locale and one method shadows itself

models/resource_booking.py in Brenden's branch adds four portal-rendering helpers on resource.booking: _get_portal_timezone, _get_portal_timezone_label, _get_portal_start_display, _get_portal_duration_display. Two concrete problems:

  1. Duplicate definition. _get_portal_timezone_label is defined twice in the same class (lines 79–93 and 116–133 in his version). Python silently keeps the second body, so the first is dead code. The two implementations are not equivalent — real correctness regression in addition to dead code.
  2. Hardcoded US English. _get_portal_timezone_label ships a hardcoded dict mapping nine America/* and US/* tz names to lowercase strings like "central time". _get_portal_start_display hardcodes M/D/YY h:mm AM/PM. Neither uses res.lang formatting or _() for translation. Will fail OCA review on i18n grounds.

Plan: push these helpers into the consumer (website_appointment_booking) where the US-tenant assumption originates, OR rewrite them with res.lang.format_datetime + babel.dates.get_timezone_name + self.env._().

Followup B — portal template + SCSS refresh

Brenden's branch also ships visual portal changes (resource_booking/templates/portal.xml 120+/82-, new resource_booking/static/src/scss/portal.scss 171+/0). Visual/UX changes are taste-dependent and bundling them with this PR would slow it down on review concerns unrelated to the behavior change here. Holding for a separate IMP PR after we've seen Brenden's screenshots reproduce on a Runboat build.

Source

Combined review branch: 18.0-techsystech-review-resource_booking carries everything from Brenden's branch (these followups + this PR's content + items already extracted into sibling PRs).

For later review with Brenden — not yet pinged.

@dnplkndll dnplkndll force-pushed the 18.0-imp-resource_booking-booking_buffer branch 3 times, most recently from dab13c8 to 9cd32e3 Compare May 16, 2026 01:57
@dnplkndll
Copy link
Copy Markdown
Author

OCA upstream readiness cleanup

Force-pushed an amend that drops two non-substantive files from the diff so this branch is ready to lift directly into an OCA upstream PR:

  • Reverted resource_booking/__manifest__.py version bump — OCA convention is that contributors don't bump; /ocabot merge {patch|minor|major} does it on merge.
  • Reverted resource_booking/README.rst and static/description/index.html — these are auto-generated by oca-gen-addon-readme from readme/* fragments. The pre-existing diff was pure generator-version drift (pinned maintainer-tools version produces slightly different output than what currently lives in upstream); the OCA bot regenerates post-merge so these should not appear in a PR.

The substantive code/tests are unchanged. Used SKIP=oca-gen-addon-readme git commit --amend so the regen hook didn't re-stage the bot files; all other pre-commit hooks ran clean.

Reference: OCA quality checklist, rules A3 (no manual version bumps) and A5 (no direct README.rst edits).

@dnplkndll dnplkndll force-pushed the 18.0-imp-resource_booking-booking_buffer branch 2 times, most recently from a2366b0 to 9db1b78 Compare May 16, 2026 11:58
…ldown)

Add a Float field booking_buffer (hours, SQL-constrained nonnegative,
default 0) on resource.resource. When non-zero, the resource is treated
as busy for that many hours after each scheduled booking ends, so the
next slot cannot start within the cooldown window.

Wire it into _get_intervals via a new _get_buffered_booking_intervals
helper that scans recently-ending overlapping bookings sharing at least
one buffered resource, then subtracts the cooldown windows from the
candidate availability. Default 0 preserves the existing back-to-back
slot behavior.

Useful for resources that need cleanup/reset/turnaround time between
appointments (rooms, equipment, etc.) without inflating the booking
duration itself.

Co-Authored-By: Brenden Eshbach <brenden@techsystech.com>
@dnplkndll dnplkndll force-pushed the 18.0-imp-resource_booking-booking_buffer branch from 9db1b78 to 1e5644e Compare May 16, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant