← Back to Pull requests

[19.0][FIX] stock_picking_invoice_link: restrict the invoice link to invoicing users #2442

Closed
unknown closed this pull request without merging on Sep 28, 2026 17:28 UTC
View on GitHub
unknown unknown commented on Sep 01, 2026 17:31 UTC
Author

Problem

A user with Inventory / User access and no accounting access cannot open an
internal transfer once this module is installed. The form fails with:

AccessError: Failed to read field stock.picking.invoice_ids
You are not allowed to access 'Journal Entry' (account.move) records.

The picking form injects invoice_ids (m2m to account.move) and the Invoice
stat button with no groups. Reading a many2many triggers a search on the
comodel, and warehouse profiles have no read access on account.move, so an
accessory piece of information ends up blocking the core operation of the role.

The same happens on the stock.move form with invoice_line_ids
(account.move.line).

Why groups on the field was not enough

invoice_line_ids already carried groups="account.group_account_invoice", but
the surrounding <group> has an invisible="invoice_line_ids == []" modifier.
View postprocessing adds the field back as an invisible node so the modifier can
be evaluated:

<field name="invoice_line_ids" invisible="True" readonly="True"
       data-used-by="invisible='invoice_line_ids == []' (group,invoice_line)"/>

so the field is read anyway and the form still breaks. The fix puts groups on
the node that carries the modifier, which removes both the modifier and the
field.

Change

views/stock_view.xml only:

  • picking form: groups="account.group_account_invoice" on the invoice_ids

  • field and on the stat button (the button holds the
    invisible="invoice_count == 0" modifier, so it goes away with it);
  • move form: groups moved from the invoice_line_ids field to the enclosing

  • <group name="invoice_line">.

    Nothing changes for users who can already see invoices.

    Test plan

    On a 19.0 database with this module installed, a user whose only groups are
    base.group_user + stock.group_stock_user:

  • before: picking.read(<fields exposed by stock.view_picking_form>) raises

  • AccessError on account.move; the same on stock.view_move_form raises on
    account.move.line;
  • after: invoice_ids / invoice_count / invoice_line_ids are no longer

  • present in the arch returned by get_view() for that user, and reading every
    field the forms expose succeeds;
  • a user with account.group_account_invoice still gets the stat button, the

  • invoice lines group and invoice_count, and reaches the invoice from the
    picking.

    The list views (stock.vpicktree, stock.view_move_tree) never exposed these
    fields, and were verified not to raise for the restricted user.

    The same asymmetry is present on 18.0; a backport can follow once this is
    reviewed.

    Diff: 331 lines (+248 / -83) across 4 files Reviewer: dreispt Review duration: 38876m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 331 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.347
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2442"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    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: 42.1% (MEDIUM) · Higher = larger blast radius
    42.1%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 16.6% · Safe to merge
    16.6%