Skip to content

[19.0][FIX] base_tier_validation: recompute can_review when a sibling review changes status#54

Open
bosd wants to merge 1 commit into
OCA:19.0from
bosd:19.0-fix-can_review-sibling-recompute
Open

[19.0][FIX] base_tier_validation: recompute can_review when a sibling review changes status#54
bosd wants to merge 1 commit into
OCA:19.0from
bosd:19.0-fix-can_review-sibling-recompute

Conversation

@bosd

@bosd bosd commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Problem

tier.review.can_review is a stored computed field, but its value (_can_review_value) depends on the other reviews of the same record — it returns True only for the review holding the lowest pending sequence. Its @api.depends can only list this review's own fields (status, sequence, approve_sequence, model, res_id), because the link to the siblings is the generic (model, res_id) reference, which @api.depends can't traverse.

So when one review's status changes, the siblings' stored can_review is not recomputed. The visible symptom: once the first tier of an approve_sequence chain is approved, the next tier's stored can_review stays False, so review_user_count (which filters can_review = True) never surfaces the record in that reviewer's systray until something else happens to touch the review's own fields. In practice large backlogs of pending approvals silently disappear from reviewers' systrays.

Fix

Recompute the siblings' can_review whenever a review's status is written — scoped per (model, res_id) via env.add_to_compute. This expresses the cross-review dependency that @api.depends cannot.

Test

test_19d_can_review_recomputes_on_sibling_status_change: a later-tier review is pending-but-not-lowest (can_review correctly False); approving the first tier (a sibling status change) must flip the later tier's stored can_review to True. Fails before the fix (stays False), passes after.

…w changes

``tier.review.can_review`` is a *stored* computed field, but its value
(``_can_review_value``) reads the *other* reviews of the same record -- it
returns True only for the review holding the lowest pending sequence. Its
``@api.depends`` can only list this review's own fields, because the link to the
sibling reviews is the generic ``(model, res_id)`` reference, which
``@api.depends`` cannot traverse.

As a result, changing one review's status does not recompute the others'
``can_review``. The most visible symptom: once the first tier of an
``approve_sequence`` chain is approved, the next tier's stored ``can_review``
stays False, so the record never appears in that reviewer's systray
(``review_user_count`` filters on ``can_review = True``) until something else
happens to touch the review's own fields.

Recompute the siblings' ``can_review`` explicitly whenever a review's ``status``
is written (scoped per ``(model, res_id)`` via ``env.add_to_compute``). Adds
``test_19d_can_review_recomputes_on_sibling_status_change``.
@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 Jun 23, 2026
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