Skip to content

[19.0][FIX] base_tier_validation: auto-promote first review to pending - #21

Merged
OCA-git-bot merged 5 commits into
OCA:19.0from
bosd:19.0-fix-auto-promote-first-review
May 13, 2026
Merged

OCA-git-bot merged 5 commits into
OCA:19.0from
bosd:19.0-fix-auto-promote-first-review

Conversation

@bosd

@bosd bosd commented May 12, 2026

Copy link
Copy Markdown
Contributor

Problem

After request_validation() reviews can stay in waiting forever when neither of these is true:

  • the user requesting the validation is themself the first reviewer (so the record carries can_review=True), or
  • at least one tier definition has notify_on_create=True.

Concrete repro:

  1. Create two tier definitions on a journal entry, both with approve_sequence=True, sequence 10 and 20, different reviewers, and notify_on_pending=True (only).
  2. Submit a journal entry that matches the definition domains, requested by a user who is not a reviewer of either tier.

Observed:

  • Both reviews stay in waiting.
  • No reviewer is notified.
  • The yellow banner shows This Record needs to be validated. tier.review() -- because _compute_next_review leaks the empty recordset to its Char field when no review is pending.

Expected (and the behaviour originally introduced when merging base_tier_validation_waiting -- see 994b3f7):

  • The lowest-sequence review is auto-promoted to pending.
  • notify_on_pending reviewers are notified.
  • The banner shows Next: <definition name>.

The 19.0 migration (66f964a) refactored the auto-promote side-effect out of _compute_can_review into a separate _update_review_status method, but only wired it back into the two narrow paths above. The tests for this flow (test_19_waiting_tier and test_20_no_sequence) were updated to call _update_review_status manually instead of catching the regression.

Fix

  • Call created_trs._update_review_status() unconditionally inside request_validation so the available review(s) are promoted to pending right away. _update_review_status is idempotent (skips non-waiting), so the existing _update_counter path stays correct.
  • Coerce next_review to False when no review is pending (so the Char field doesn't end up holding the repr of an empty recordset).
  • Remove the now-unnecessary manual _update_review_status() calls from test_11_add_comment, test_19_waiting_tier, test_20_no_sequence and update test_28_computed_state_field to assert the auto-promoted state. Add an explicit regression assertion for the next_review value in test_19.

Test plan

  • pytest base_tier_validation/tests (full module suite) green
  • Manual repro from the issue: 2 tier definitions by sequence, notify_on_pending=True, validation requested by a non-reviewer -- first reviewer reaches pending and receives the notification; banner reads Next: <definition name>.

CC @LoisRForgeFlow

After ``request_validation()`` the lowest-sequence review (or every
review when ``approve_sequence`` is not used) must reach the ``pending``
state immediately so the reviewer can act on it and so that
``notify_on_pending`` notifications fire.

Before this commit ``_update_review_status`` was only called when:

- the requesting user was themself the first reviewer (so the record
  had ``can_review=True`` and ``_update_counter`` was invoked), or
- at least one tier definition had ``notify_on_create=True``.

In every other case (the common one: setting only
``notify_on_pending``, validation requested by someone who is not the
tier-1 reviewer) all reviews stayed in ``waiting`` indefinitely and
no reviewer was notified. ``next_review`` also leaked the empty
recordset to its ``Char`` field, producing ``tier.review()`` in the
"This Record needs to be validated" banner.

Restore the original behaviour from the
``base_tier_validation_waiting`` merge (994b3f7) by always promoting
the available review(s) right after ``request_validation`` creates
them, and coerce ``next_review`` to ``False`` when no review is
pending.

Tests updated accordingly: the previously-needed manual
``_update_review_status()`` calls are removed, and an explicit
regression assertion is added for the ``next_review`` value.
@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 12, 2026
bosd added 3 commits May 12, 2026 17:26
When approve_sequence=True, only the reviewer at the lowest
review.sequence may be notified via notify_on_pending. The next
reviewer in the chain must stay unsubscribed and must not receive a
message until their predecessor has approved.

Adds test_19a_notify_on_pending_sequence_negative covering both
the positive (first reviewer notified) and negative (second reviewer
NOT subscribed, NOT notified) sides of that contract, so a future
regression of the auto-promote / notify-on-pending plumbing is caught
immediately.
…py defs

The negative test was failing on CI because test_field=5.0 also matched
definition_2/definition_3 from common.py (domain test_field > 3.0),
which pushed the new def_first to a non-minimum review sequence so it
never auto-promoted. Use test_field=2.5 (matches no common.py def) and
restrict the new definitions to exactly that value.

Also:
- Add a HISTORY.md entry for 19.0.1.0.1
- Run ruff-format / oca-gen-addon-readme regenerated artefacts
…iew_available

The tier-validation subtypes are marked default=False in
mail_data.xml, so a plain message_subscribe(partner_ids=...) leaves
the partner subscribed only to default subtypes. The subsequent
message_post(subtype_xmlid='mt_tier_validation_requested', ...)
then routes to nobody -- notified_partner_ids ends up empty even
though the reviewer's definition has notify_on_pending=True.

Mirror what _notify_review_requested already does: pass
subtype_ids to message_subscribe and short-circuit when there
is no reviewer to notify (avoid posting a stray subtype message that
nobody is subscribed to).
@bosd bosd changed the title [FIX] base_tier_validation: auto-promote first review to pending [19.0][FIX] base_tier_validation: auto-promote first review to pending May 12, 2026
Adds test_19b_notify_review_available_no_op_when_no_users which
calls _notify_review_available directly with a review whose
definition has notify_on_pending=False. Asserts no follower is
added and no chatter message is posted -- covering the
if not users_to_notify: continue guard that codecov flagged.
@yankinmax

Copy link
Copy Markdown
Contributor

Hello @bosd , I see your point and it's a good catch indeed.
I'll check other PR's usage of explicit _update_review_status call I've added:

@yankinmax yankinmax left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@LoisRForgeFlow LoisRForgeFlow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 19.0-ocabot-merge-pr-21-by-LoisRForgeFlow-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 491115c into OCA:19.0 May 13, 2026
6 of 7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 26bb76e. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants