← Back to Pull requests

[19.0][IMP] stock_production_lot_active: refuse to archive a lot with stock on hand #2586

Open
AungKoKoLin1997 opened this pull request with 94 lines diff across 6 files
View on GitHub
AungKoKoLin1997 AungKoKoLin1997 commented on Nov 26, 2026 07:31 UTC
Author

Refuse to archive a lot while an internal or transit location still holds stock of it, as Odoo already does for locations. Stock that has left the company (customer, scrap, supplier locations) does not count. Scripts can pass do_not_check_quant in the context, the same key Odoo uses for the location check, to archive regardless.

@qrtl QT6978

Diff: 94 lines (+92 / -2) across 6 files Reviewer: yostashiro Review duration: 7820m
All Vouch review confidence checks passed
Residual risk 0.11 = Change Risk (0.38) × (1 − Review Confidence (0.72)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.38 · 94 lines diff across 6 files
0.38
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.54 · 3 substantive comment(s)
0.54
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
71%
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.272
Real PR Conversation Timeline
6 items
OCA-git-bot OCA-git-bot commented on Nov 26, 2026 07:31 UTC
Bot

Hi @ThomasBinsfeld,
some modules you are maintaining are being modified, check this out!

yostashiro yostashiro commented on code on Nov 26, 2026 10:44 UTC
Code Review
stock_production_lot_active/models/stock_production_lot.py:1
@@ -17,3 +18,35 @@ def _check_unique_lot(self):
         another inactive entry we have to set the active_test flag to False.
         """
         return super(StockLot, self.with_context(active_test=False))._check_unique_lot()
+
+    @api.constrains("active")
+    def _check_archived_without_stock(self):
+        archived = self.filtered(lambda lot: not lot.active)
+        if not archived or self.env.context.get("do_not_check_quant"):
+            return
+        # sudo: stock the user's companies hide still counts.

Thought this would be easier to understand.

        # sudo: also count stock in companies the user cannot see.

yostashiro yostashiro approved these changes on Nov 26, 2026 10:45 UTC
Approved Reviewer

Approved these changes.

StefanRijnhart StefanRijnhart approved these changes on Nov 30, 2026 07:52 UTC
Approved Reviewer

Approved these changes.

OCA-git-bot OCA-git-bot commented on Dec 01, 2026 07:40 UTC
Bot

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Reviewers
Assignees
AungKoKoLin1997 AungKoKoLin1997
Labels
risk: low confidence: 71.6% 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: 37.6% (MEDIUM) · Higher = larger blast radius
37.6%
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: 71.6% · Lower = rushed or shallow review
71.6%
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: 10.7% · Safe to merge
10.7%