← Back to Pull requests

[16.0][BKP] stock_reserve_sale: backport to v16 #2684

Closed
unknown closed this pull request without merging on Nov 16, 2026 17:47 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 13:57 UTC
Author

Back-port of stock_reserve_sale to 16.0, plus a few improvements on top.

The module was never merged in 16.0 (#1695 and #1788 were closed). This branch carries the whole history of the module from 17.0.

[MIG] stock_reserve_sale: back-port to 16.0


Adapts the 17.0 module to 16.0

[IMP] stock_reserve: picking type from location warehouse


Reservations always got the first delivery type of the company, whatever their source location. A new _get_picking_type(location, company_id) method returns the delivery type of the source location's warehouse, and falls back to the company's first delivery type when the location is not in a warehouse. default_get uses it.

[IMP] stock_reserve_sale: use source location picking type


The reservation transfer used the delivery type of the sale order's warehouse, even when stock was reserved from another warehouse. The wizard now uses _get_picking_type with the source location, and also sets the picking type on the reservation, so the move and its transfer always match.

[IMP] stock_reserve_sale: add stock reservation policy


New company setting Stock Reservation Policy in Sales > Configuration > Settings > Quotations & Orders:
  • Always reserve the ordered quantity (default, previous behaviour): the missing quantity is reserved when stock becomes available.

  • Reserve the available quantity: only the quantity available in the source location is reserved.

  • Reserve only if the full quantity is available: a line is reserved only when its whole quantity is available.
  • Availability is computed the same way Odoo does when reserving: free quantity in the source location and its children. Consumable products and locations that do not track stock always use the ordered quantity.

    [IMP] stock_reserve_sale: make reservation transfers optional


    New company setting Reservation Transfers (enabled by default, previous behaviour). When disabled, reservations are created as plain stock moves without a delivery transfer, as in stock_reserve. This avoids reservation transfers showing up among the deliveries, where they could be validated by mistake.

    [IMP] stock_reserve_sale: add lines to the reservation wizard


    New transient model sale.stock.reserve.line. The wizard lists the lines to reserve with their ordered quantity, the quantity available in the source location and the quantity to reserve. That quantity defaults according to the reservation policy and can be changed, and it is checked against the policy. Lines that will not be fully reserved are highlighted, so the user sees a partial reservation before confirming. The ROADMAP is updated accordingly.

    [FIX] stock_reserve_sale: compute all lines reserved per line


    Comparing the number of reservations with the number of lines fails
    when a line has several reservations, as the components of a kit do:
    the order can be flagged as fully reserved while a line is not, or the
    other way around. Check instead that every line has a reservation.
    It ensures the logic is fine also when using https://github.com/OCA/stock-logistics-warehouse/pull/2686

    [IMP] stock_reserve_sale: default to order warehouse location


    The source location of the reservation wizard defaulted to the stock
    location of the first warehouse of the company, whatever the warehouse
    of the sale order. Default to the stock location of the warehouse of the
    selected sale orders instead, and keep the previous default when they
    belong to different warehouses.

    Diff: 440 lines (+330 / -110) across 5 files Reviewer: eduezerouali-tecnativa Review duration: 36229m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 440 lines diff across 5 files
    0.45
    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.364
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2684"
    general weight: 0.35
    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: 45.3% (MEDIUM) · Higher = larger blast radius
    45.3%
    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: 17.9% · Safe to merge
    17.9%