[13.0] [FIX] stock_inventory_include_exhausted: Filtered with product who has already created inventory line to avoid duplicated line.

In some cases
This commit is contained in:
Nicolás Mac Rouillon
2021-07-02 10:06:19 -03:00
parent c68e606ef4
commit e67d4d117e
2 changed files with 5 additions and 0 deletions

View File

@@ -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)

View File

@@ -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(