[17.0][FIX] stock_inventory: link the applied move lines when they are created #2711
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 230 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.326
Real PR Conversation Timeline
1 comments
"Review active on #2711"
general
weight: 0.35
petrus-v
After the moves are done,
_apply_inventorylinks "the last move line" on each quant's product, lot and location to the inventory. That guess fails in two ways:_action_donereserves another lot of the same location, which creates a newer move line. The search then links that picking line to the inventory and prefixes its reference, and the inventory's own line stays unlinked. It's the symptom reported in #2499.create_date, which every line of a transaction shares, so it can pick any line created in the same transaction. We saw lines linked to the wrong inventory, and inventories left with no lines.Change
_get_inventory_move_valueswritesinventory_adjustment_idand"<inventory>: <move name>"on the move line values, so each line is linked when it is created. Only lines built through this method are linked, which covers what core creates when applying.move_quants()builds its moves with the same method, so only the quants being applied are linked:_apply_inventorypasses their ids in the context.ValueError("No move lines have been created")are gone. A quant applied without an inventory no longer rewrites the line the search happened to find.stock_move_ids. That made two concurrent applies of one inventory conflict, and the retried one saw every quant done and auto-completed it._apply_inventorynow writes the inventories when auto-complete is on, to keep that.test_14reproduces the re-reservation and fails without the fix.test_15checks that relocating a quant under an in-progress inventory stays unlinked.AI assistance: prepared with Claude Code (Claude Opus 5.5); reviewed and tested by me.