← Back to Pull requests

[19.0][FIX] stock_inventory: do not fail when core creates no move line #2651

Closed
unknown closed this pull request without merging on Nov 10, 2026 09:38 UTC
View on GitHub
unknown unknown commented on Sep 22, 2026 14:46 UTC
Author

Problem

Any product.product import that maps Quantity On Hand fails on every row whose
value matches the current on-hand quantity — which, for a product being created, means
0, or simply an empty cell that base_import reads as 0.0:

Unknown error during import: <class 'ValueError'>: No move lines have been created

Cause

Two changes in 19.0 combine:

1. product.qty_available gained an inverse (addons/stock/models/product.py:270). It
creates a quant and applies it with from_inverse_qty=True in the context. In 17.0 and
18.0 the field had no inverse at all, so this code path did not exist.

2. stock.quant._apply_inventory now skips move creation entirely for that case
(addons/stock/models/stock_quant.py:1008-1011):

if quant.env.context.get('from_inverse_qty') and quant.product_uom_id.compare(quant.inventory_diff_quantity, 0) == 0:
    continue

In 17.0 and 18.0 the loop had no such branch — a zero difference still produced a
zero-quantity move, so a move line always existed afterwards. That is the assumption
this module's override was written against.

With no move created, the override finds no move line and raises.

Fix

Skip the quant when core deliberately created no move, and keep raising everywhere else —
for a real inventory adjustment core still always creates one.

Tests

Two tests added, covering both sides of the branch: a product created with a zero
qty_available (no move expected) and with a non-zero one (move expected). The first
reproduces the failure on 19.0 and passes with the fix; the second passes either way and
guards against over-broad skipping.

Diff: 208 lines (+156 / -52) across 2 files Reviewer: micheledic Review duration: 70252m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 208 lines diff across 2 files
0.36
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.320
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2651"
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: 36.4% (MEDIUM) · Higher = larger blast radius
36.4%
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: 14.4% · Safe to merge
14.4%