From 1e37ad3a179d5856460cf17b252f6288da392f4e Mon Sep 17 00:00:00 2001 From: paso-odoo Date: Thu, 23 Mar 2023 10:20:58 +0000 Subject: [PATCH] [FIX] stock: expected singleton issue in quants when lot/sn number If applied, this commit will solve the issue of the singleton when there are 2 quants with the same location and same products but one quant with a lot and another quant without a lot number. Steps to produce: - Create one quant with location-1 and without lot number. - Create another quant with location-1 but with the lot number. - Create 3rd quant with location-1 with same lot number as step2. The error will raise in 3rd step as it is not accepting the 2 quants where one is with lot number and another is without lot number. see - https://tinyurl.com/2hqrgmwm sentry - 4024572562 closes odoo/odoo#119152 X-original-commit: 05a7f5c04804423cfc3a833a1b3f0b5eec3fc147 Signed-off-by: Tiffany Chang --- addons/stock/models/stock_quant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 714b7caecaa..6746e5bb295 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -803,7 +803,7 @@ class StockQuant(models.Model): self.product_id, self.location_id, lot_id=self.lot_id, package_id=self.package_id, owner_id=self.owner_id, strict=True) if quant: - self.quantity = quant.quantity + self.quantity = quant.filtered(lambda q: q.lot_id == self.lot_id).quantity # Special case: directly set the quantity to one for serial numbers, # it'll trigger `inventory_quantity` compute.