Skip to content

[19.0][IMP] base_tier_validation: warn at definition save if reviewer lacks model ACL#31

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

[19.0][IMP] base_tier_validation: warn at definition save if reviewer lacks model ACL#31
bosd wants to merge 3 commits into
OCA:19.0from
bosd:19.0-imp-base_tier_validation-warn-no-access-config

Conversation

@bosd
Copy link
Copy Markdown
Contributor

@bosd bosd commented May 13, 2026

Summary

Catch the "invalid tier definition" misconfiguration at config time instead of letting it fail silently later.

When an admin sets a reviewer (individual user or group) that has no ir.model.access read on the tier's target model, an onchange warning explains the problem and names the affected user(s). The warning is non-blocking — the record can still be saved. Legitimate workflows (admin is about to add the user to the group, ir.rule grants per-record access on demand, multi-company quirks) keep working; the warning just makes it impossible to misconfigure this silently.

Scope

review_type Behaviour
individual Check reviewer_id
group Check every member of reviewer_group_id.user_ids
field Skipped — the reviewer only resolves at validation time from a field on the document. The chatter notification at request_validation time (separate PR) catches that case.

Tradeoff (worth calling out for review)

check_access('read') is a model-level check. Per-record ir.rule can grant or revoke access at runtime. So:

  • False positive: the warning fires, but ir.rule would have allowed access on specific records → admin sees the warning and ignores it. Fine; non-blocking.
  • False negative: no warning, but ir.rule blocks access on some records → still silently broken for those. The chatter PR catches this.

The message is worded "may not be able to read" on purpose. Better than silent failure.

Test plan

Three tests cover the three branches:

  • test_definition_onchange_warns_when_reviewer_lacks_access (individual)
  • test_definition_onchange_warns_when_group_member_lacks_access (group)
  • test_definition_onchange_skips_field_review_type (field — no warning)

Each unlinks the tester model's ir.model.access, builds a tier.definition.new(...) with the relevant reviewer config, and asserts the onchange returns / does not return a warning dict.

Follow-up

A separate PR will add a chatter notification on request_validation for the cases this onchange can't cover (field reviewer, dynamic group membership that changed after the definition was saved, ir.rule-only restrictions).

… model ACL

Make misconfigured tier definitions visible at config time instead of
silently producing reviews nobody can act on.

When the admin sets a reviewer (individual user or group) that has no
ir.model.access read on the tier's target model, an onchange warning
explains the problem and names the affected user(s) -- but does not
block the save. Legitimate workflows (the user is about to be added
to the group, ir.rules grant per-record access, ...) still go through.

Skipped for review_type='field': the reviewer only resolves at
validation time from a field on the document, so we can't check it
in advance. The chatter notification at request_validation time
(separate PR) catches that case.

The helper deliberately checks only model-level ACL: per-record
ir.rule restrictions can grant or revoke access at runtime, so the
warning is worded as "may not be able to read" rather than asserting
a definite block. False positives are preferable to silent failure.

Tests cover all three branches (individual, group, field).
@OCA-git-bot
Copy link
Copy Markdown
Contributor

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

bosd added 2 commits May 14, 2026 09:27
Two issues in the onchange tests:

- Test setup unlinked the public tier.validation.tester ACL after
  the .new() definition had already been built and the onchange had
  already called check_access once. The ir.model.access ormcache
  retained the earlier "allowed" decision, so the second onchange
  call still saw the reviewer as having access. Revoke the ACL
  before constructing the .new() record, and call
  ir.model.access.call_cache_clearing_methods() to be sure subsequent
  check_access invocations re-evaluate. Extract to a helper used by
  all three onchange tests so they exercise the same path.

- On .new() records, the stored related ``self.model`` field can
  still be empty depending on cache state, which made the onchange
  silently return None in the failing CI environment. Read the model
  name directly off ``self.model_id.model`` (the m2o navigation) so
  it's always populated when ``model_id`` has been set.
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