Skip to content

[IMP] resource_booking: cap suggested slots with max_advance_booking_days#3

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

[IMP] resource_booking: cap suggested slots with max_advance_booking_days#3
dnplkndll wants to merge 1 commit into
18.0from
18.0-imp-resource_booking-max_advance_booking_days

Conversation

@dnplkndll
Copy link
Copy Markdown

Summary

Adds an integer field max_advance_booking_days on resource.booking.type (SQL-constrained nonnegative, default 0) and gates _get_available_slots to skip starts beyond now + N days. Default 0 preserves the existing unbounded behavior.

Useful when a booking type should not let requesters reserve weeks or months out — e.g. office desks released only one week ahead, sales call windows that should not commit dates beyond a planning horizon.

Test plan

  • CI green
  • Runboat build comes up
  • Manual: set max_advance_booking_days = 7 on a booking type; verify portal scheduling page only offers slots within the next 7 days

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-max_advance_booking_days branch 2 times, most recently from 7b0d7be to 123dd03 Compare May 16, 2026 01:27
…days

Add an integer field max_advance_booking_days on resource.booking.type
(SQL-constrained nonnegative, default 0) and gate _get_available_slots
to skip starts beyond now + N days. Default 0 preserves the existing
unbounded behavior.

Useful when a booking type should not let requesters reserve weeks or
months out (e.g. office desks released only one week ahead, sales call
windows that should not commit to dates beyond a planning horizon).

Co-Authored-By: Brenden Eshbach <brenden@techsystech.com>
@dnplkndll dnplkndll force-pushed the 18.0-imp-resource_booking-max_advance_booking_days branch from 123dd03 to 768dbea 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).

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