[FIX] resource_booking: portal home and listing tolerate users without read access#5
[FIX] resource_booking: portal home and listing tolerate users without read access#5dnplkndll wants to merge 2 commits into
Conversation
3ab6123 to
24c8624
Compare
CI fixFirst push failed Reverted the tz refactor — this PR is now strictly the two Diff scope after revert: 5 files (controllers/portal.py, tests/test_portal.py, manifest.py version bump, README.rst + index.html re-gen), +70/-26. |
…t read access
A user landing on /my that lacks resource.booking read access (e.g. an
internal user not in resource_booking.group_user, an internal account
created by another website-facing module) used to hit a hard AccessError:
- _prepare_home_portal_values called search_count([]) unguarded, breaking
the entire portal home page when "booking_count" was in counters.
- portal_my_bookings called search_count([]) unguarded, breaking the
/my/bookings listing for the same users.
Both paths now check Booking.has_access("read") and degrade gracefully
(zero counter, empty list page) instead of raising. Portal users with
the dedicated ACL row keep the existing behavior unchanged.
Distinct from upstream 1c59c21 ([FIX] resource_booking: access error on
normal calendar) which fixed a different surface: the calendar event
form's resource_booking_ids field now hidden via groups= for users
without booking permissions. The portal AccessError addressed here is
a separate bug.
Co-Authored-By: Brenden Eshbach <brenden@techsystech.com>
24c8624 to
07abb82
Compare
OCA upstream readiness cleanupForce-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:
The substantive code/tests are unchanged. Used Reference: OCA quality checklist, rules A3 (no manual version bumps) and A5 (no direct README.rst edits). |
…ests Two follow-ups from review of the no-access fix: - portal_my_bookings: unify the no-access branch with the normal path. Previously the no-access branch returned an empty dict for `pager`, which is technically harmless because the current template doesn't read pager, but is fragile against future template inheritance. Now has_access is computed once, search_count is gated, and the rest of the function (real portal.pager(total=0), recordset, session, render) runs through the single existing code path. - Tests: replace fragile "no Traceback in response" assertions with positive DOM markers. Home test now asserts the .o_portal_my_home / .o_portal_wrap wrapper renders; listing test asserts the empty-state alert string from the QWeb template appears. Both confirm the template actually rendered rather than just "did not crash".
Summary
A user landing on
/mythat lacksresource.bookingread access (e.g. an internal user not added toresource_booking.group_user, or an internal account created by another website-facing module) used to hit a hardAccessError:_prepare_home_portal_valuescalledsearch_count([])unguarded, breaking the entire portal home page whenbooking_countwas incounters.portal_my_bookingscalledsearch_count([])unguarded, breaking the/my/bookingslisting for the same users.Both paths now check
Booking.has_access("read")and degrade gracefully (zero counter, empty list page). Portal users with the dedicated ACL row keep the existing behavior unchanged.Distinct from upstream
1c59c21The recent OCA fix
1c59c21 [FIX] resource_booking: access error on normal calendaraddresses a different surface — it addsgroups="resource_booking.group_user"to theresource_booking_idsfield on thecalendar.eventform so non-booking users opening a calendar event don't see the (forbidden) field.This PR addresses the portal path, not the backend calendar form. Both fixes are needed.
Tests
test_portal_home_no_resource_booking_access— internal user without booking ACL row gets a 200 response on/my(no traceback / AccessError in response body).test_portal_my_bookings_no_access_renders_empty— same user gets a 200 on/my/bookings, rendering an empty list page.Test plan
base.group_user(noresource_booking.group_usermembership) and confirm/myand/my/bookingsrender without errors.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`.