Skip to content

[19.0][IMP] base_tier_validation: chatter warning at request_validation if reviewers lack access#32

Open
bosd wants to merge 4 commits into
OCA:19.0from
bosd:19.0-imp-base_tier_validation-warn-no-access-runtime
Open

[19.0][IMP] base_tier_validation: chatter warning at request_validation if reviewers lack access#32
bosd wants to merge 4 commits into
OCA:19.0from
bosd:19.0-imp-base_tier_validation-warn-no-access-runtime

Conversation

@bosd
Copy link
Copy Markdown
Contributor

@bosd bosd commented May 13, 2026

Summary

Make stalled-by-misconfiguration tier validations visible at runtime instead of letting them silently freeze.

After request_validation creates the tier.review rows for a record, the new _warn_reviewers_lacking_access helper checks each reviewer against the validated model's ir.model.access. For any reviewer that fails the model-level read check:

  • a server-level WARNING is logged (record name, id, reviewer logins) — enough for an admin to debug from logs;
  • a chatter message is posted on the validated document naming the affected reviewer(s) and explaining the workflow will stall until they get access or are replaced.

This catches the cases the onchange warning at definition save (#31) can't:

  • review_type='field' (reviewer only resolves at validation time);
  • group membership changed after the definition was saved;
  • ir.rule-only restrictions that bypass model-level ACL.

Reproduction

  1. As admin, create a tier definition on account.move with the demo user as reviewer.
  2. Log in as admin; create a journal entry; request validation.
  3. Before: nothing visible to anyone — demo can't see the document, admin doesn't know why the workflow is stuck.
  4. After: chatter on the journal entry says "the following reviewer(s) may not be able to read this document...: Demo. The workflow will remain pending until they get access or are replaced." Server log also gets a WARNING.

Tradeoff (worth calling out for review)

check_access('read') is model-level. Per-record ir.rule can grant or revoke access dynamically:

  • False positive: chatter says "may not be able to read", but ir.rule would actually allow access on this specific record → admin sees a noise message. Wording is "may not be able to" to soften this.
  • False negative: chatter stays silent, but ir.rule blocks access on this specific record → still silently broken. Less surface area than today, but not a guarantee.

Better than silent failure either way.

Test plan

Two tests:

  • test_request_validation_warns_reviewer_without_access: unlinks the tester model's ir.model.access, requests validation as test_user_2, asserts a chatter message naming the reviewer was posted.
  • test_request_validation_no_warning_when_reviewer_has_access: same flow with the default public ACL in place, asserts no spurious chatter message.

Companion PR

#31 covers the same problem at config time (onchange warning on tier.definition). They're independent — review either order.

…reviewers lack access

Make stalled-by-misconfiguration tier validations visible at runtime
instead of letting them silently freeze.

After request_validation creates the tier.review rows for a record,
check each reviewer against the validated model's ir.model.access.
For any reviewer that fails the model-level read check:

- a server-level WARNING is logged (definition author + reviewer login
  + model + record id, enough for an admin to debug from logs);
- a chatter message is posted on the validated document, naming the
  affected reviewer(s) and explaining the workflow will stall until
  they get access or are replaced.

This catches the cases the onchange warning at definition save can't:
- review_type='field' (reviewer only resolves at validation time);
- group membership changed after the definition was saved;
- ir.rule-only restrictions that bypass model-level ACL.

Model-level ACL only: per-record ir.rule may grant or revoke access
at runtime, so false positives are possible. The chatter message
says "may not be able to read" rather than asserting a guaranteed
block. False positives are still preferable to silent failure.

Tests cover both directions: chatter posted when reviewer lacks
access, no chatter spam when reviewer has access.
@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @LoisRForgeFlow,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added mod:base_tier_validation Module base_tier_validation series:19.0 labels May 13, 2026
bosd added 2 commits May 14, 2026 09:26
…ning

- ruff B023: bind `rec` in the per-record filter lambda via
  `lambda r, rec=rec: ...` so the lint passes and the loop body is
  not relying on late binding of the cell variable.
- Test setup: unlinking the tester model's only ir.model.access row
  also revoked access for the requester (test_user_1), making
  request_validation itself blow up before the helper had a chance to
  warn. Restrict the existing public ACL to `base.group_system`
  instead -- test_user_1 keeps access, test_user_2 (only
  base.group_user) loses it, which is the actual misconfiguration
  the chatter warning is meant to surface. Clear the ACL cache after
  the write so the helper observes the new state.
@bosd bosd force-pushed the 19.0-imp-base_tier_validation-warn-no-access-runtime branch 2 times, most recently from b8379f1 to cbe173e Compare May 14, 2026 15:43
@bosd bosd force-pushed the 19.0-imp-base_tier_validation-warn-no-access-runtime branch from cbe173e to b9ef4d9 Compare May 14, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:base_tier_validation Module base_tier_validation series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants