Skip to content

[FIX] resource_booking: honor all-day calendar events when computing slots#2

Open
dnplkndll wants to merge 1 commit into
18.0from
18.0-fix-resource_booking-allday-events
Open

[FIX] resource_booking: honor all-day calendar events when computing slots#2
dnplkndll wants to merge 1 commit into
18.0from
18.0-fix-resource_booking-allday-events

Conversation

@dnplkndll
Copy link
Copy Markdown

Summary

All-day calendar events store dates in start_date/stop_date and may have no start/stop datetimes (or values that fall outside the analyzer's UTC window once timezone-shifted). The previous busy-events query in _calendar_event_busy_intervals filtered solely on start/stop, so a user's all-day event (PTO, off-site, etc.) would silently fail to block booking slots on that day.

This change:

  • Extends the conflicting-events search with an OR predicate on start_date/stop_date for allday events.
  • Renders the busy interval from start_date through stop_date + 1 day in the analyzer's tz so a single all-day event blocks the full local day across calendar-tz boundaries.
  • Adds test_allday_event_blocks_booking_slot covering the regression.

Test plan

  • CI green (test, pre-commit, unreleased-deps)
  • Runboat build comes up at ledoent-calendar-18-0-fix-resource_booking-allday-events-*.runboat.hz.ledoweb.com
  • Manual: schedule an all-day event for a resource user, then attempt to book that user during the day — expect ValidationError

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-fix-resource_booking-allday-events branch 3 times, most recently from 09de56a to 2b1fee2 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).

…slots

All-day calendar events store dates in start_date/stop_date and may have
no start/stop datetimes (or values outside the analyzer's UTC window
once timezone-shifted). The previous busy-events query filtered solely
on start/stop, so a user's all-day event (PTO, off-site, etc.) would
not block booking slots on that day.

Extend the conflicting-events search with an OR predicate on
start_date/stop_date for allday events, and render their busy interval
from start_date through stop_date+1 in the analyzer's tz so a single
all-day event blocks the full local day across calendar tz boundaries.

Co-Authored-By: Brenden Eshbach <brenden@techsystech.com>
@dnplkndll dnplkndll force-pushed the 18.0-fix-resource_booking-allday-events branch from 2b1fee2 to 3b1a404 Compare May 16, 2026 11:51
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