← Back to Pull requests

[19.0][MIG] stock_exception: migration to 19.0 and adaptation to the new base_exception flow #2585

Open
unknown opened this pull request with 483 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 24, 2026 18:00 UTC
Author

Migration of stock_exception to 19.0, adapted to the current base_exception.

Why this instead of #2185

#2185 by @JordiMForgeFlow did the migration, and the stale bot closed it on 2026-09-27 without anyone reviewing it. This PR carries its commits unchanged, rebased on the current 19.0, and adds on top the adaptation the module needs: as it stood, stock_exception still drives the pre-refactor mechanism and silently stops working once the base_exception changes of #3590 and the ones that followed are in (forward ported in #3879).

@JordiMForgeFlow, happy to close this one if you would rather reopen yours and take the last commit.

The adaptation

detect_exceptions() no longer returns the exceptions: it stores them and raises BaseExceptionError, and the popup is opened by the client error handler through action_popup_exceptions().

  • action_confirm() and button_validate() just run the detection and let the error stop the flow, instead of reading its return and opening the popup themselves, which with the new mechanism never happened.

  • _must_popup_exception() returns True. Without it the default False turns the error into a soft reload: the transfer stays in draft and the user is never told why.

  • The detection runs in the current transaction where the caller has no handler for the error: the state constraint (the transfer may not be committed yet, for example one created by a sale order confirmation, and the second cursor would fail with MissingError) and the cron, which otherwise stopped on the first transfer with an exception.

  • The rules on the stock moves are checked even when a rule on the transfer already applies: super().detect_exceptions() now raises as soon as it finds one, so they were skipped and a blocking move exception could be ignored together with the others.

  • A move exception points the popup at the transfer, which is the record on screen and where the exception is stored, as sale_exception does with the order lines. Otherwise the client falls back to a soft reload and the user is not told why.

  • The tests follow the new flow: the confirmation raises, and the stored exceptions are read through a detection with base_exception_no_rollback, since the normal flow keeps them in a transaction of its own and rolls this one back.
  • On top of the migration the module also gets demo data (a customer on credit hold with a warning rule on the transfer and a blocking one on its moves, so runboat has something to show: every shipped rule is archived), the CONFIGURE and USAGE fragments, the new OCA icon and a .po cleanup.

    Thanks @bosd for the review, the fixes and the documentation: adhoc-dev/stock-logistics-workflow#2, merged here commit by commit.

    Test plan

    Run on an Odoo 19 database with base_exception at the state of #3879:

    odoo -d <db> -i stock_exception --test-enable --test-tags /stock_exception
    

    CI runs them with base_exception from #3879, see Depends on: 10 tests, no failures, with Odoo and with OCB.

    Depends on

    _must_popup_exception(), base_exception_no_rollback and BaseExceptionError come from #3879, the forward port of the base_exception commits that are in 18.0 and missing in 19.0. Until that is merged, CI and runboat take it from the PR through the first commit of this one, [DO NOT MERGE] test-requirements.txt, which has to be dropped before merging. That is what makes the test jobs and runboat meaningful here, at the price of Detect unreleased dependencies, which is red by design while that commit is in.

    Known limitation

    After Ignore Exceptions in the popup, the wizard always calls action_confirm(). When the popup came from Validate, the transfer is not validated and the user has to click Validate again. This is the behaviour of the module as it was, kept as is here and described in USAGE.

    Diff: 483 lines (+362 / -121) across 6 files Reviewer: bosd Review duration: 8571m
    All Vouch review confidence checks passed
    Residual risk 0.38 = Change Risk (0.70) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.70 · 483 lines diff across 6 files
    0.70
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.370
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.070
    Real PR Conversation Timeline
    1 comments
    "Review active on #2585"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 46.7% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 70.5% (HIGH) · Higher = larger blast radius
    70.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 37.6% · Moderate risk
    37.6%