From e67d4d117ed9c48f1066e96fc69c5cbe5f0cbef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Mac=20Rouillon?= Date: Fri, 2 Jul 2021 10:06:19 -0300 Subject: [PATCH] [13.0] [FIX] stock_inventory_include_exhausted: Filtered with product who has already created inventory line to avoid duplicated line. In some cases --- stock_inventory_include_exhausted/models/stock_inventory.py | 2 ++ .../tests/test_stock_inventory_include_exhausted.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/stock_inventory_include_exhausted/models/stock_inventory.py b/stock_inventory_include_exhausted/models/stock_inventory.py index 3399dbb37..f1b81f789 100644 --- a/stock_inventory_include_exhausted/models/stock_inventory.py +++ b/stock_inventory_include_exhausted/models/stock_inventory.py @@ -18,6 +18,8 @@ class StockInventory(models.Model): if self.include_exhausted: domain = [("qty_available", "=", 0), ("type", "=", "product")] + product_ids = [data.get("product_id") for data in vals] + domain.append(("id", "not in", product_ids)) if self.product_ids: domain.append(("id", "in", self.product_ids.ids)) exhausted_products = self.env["product.product"].search(domain) diff --git a/stock_inventory_include_exhausted/tests/test_stock_inventory_include_exhausted.py b/stock_inventory_include_exhausted/tests/test_stock_inventory_include_exhausted.py index e8116b05c..bfc8d9001 100644 --- a/stock_inventory_include_exhausted/tests/test_stock_inventory_include_exhausted.py +++ b/stock_inventory_include_exhausted/tests/test_stock_inventory_include_exhausted.py @@ -51,6 +51,9 @@ class StockInventoryIncludeExhaustedTest(TransactionCase): self.location = self.location_model.create( {"name": "Inventory tests 1", "usage": "internal"} ) + self.location2 = self.location_model.create( + {"name": "Inventory tests 2", "usage": "internal"} + ) def _create_inventory_all_products(self, name, location, include_exhausted): inventory = self.inventory_model.create(