diff --git a/stock_by_warehouse/__manifest__.py b/stock_by_warehouse/__manifest__.py index 39d351fd88c..aced0f85119 100644 --- a/stock_by_warehouse/__manifest__.py +++ b/stock_by_warehouse/__manifest__.py @@ -1,6 +1,6 @@ { "name": "Stock by Warehouse", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "summary": """ Know the stock in all your warehouses with a simple click from the product form. diff --git a/stock_by_warehouse/models/product_product.py b/stock_by_warehouse/models/product_product.py index 44cdcf561f2..1845815818e 100644 --- a/stock_by_warehouse/models/product_product.py +++ b/stock_by_warehouse/models/product_product.py @@ -51,13 +51,17 @@ def _compute_qty_available_not_reserved(self): quants = ( self.env["stock.quant"] .with_context(lang=False) - .read_group(domain_quant, fields=["product_id", "quantity", "reserved_quantity"], groupby="product_id") + ._read_group( + domain_quant, + groupby=["product_id"], + aggregates=["quantity:sum", "reserved_quantity:sum"], + ) ) - res = {} - for quant in quants: - quantity = quant.get("quantity") - quant.get("reserved_quantity") - res[quant.get("product_id")[0]] = max(quantity, 0.0) + res = { + product.id: max(quantity - reserved_quantity, 0.0) + for product, quantity, reserved_quantity in quants + } for prod in self: prod.qty_available_not_res = res.get(prod.id, 0.0) diff --git a/stock_by_warehouse/static/src/components/warehouse/warehouse_field.xml b/stock_by_warehouse/static/src/components/warehouse/warehouse_field.xml index bf2fe609cd3..465fb93fe6b 100644 --- a/stock_by_warehouse/static/src/components/warehouse/warehouse_field.xml +++ b/stock_by_warehouse/static/src/components/warehouse/warehouse_field.xml @@ -1,7 +1,7 @@ - +

The product is available in: locations. @@ -24,7 +24,7 @@

- +

@@ -85,7 +85,7 @@
- +

diff --git a/stock_by_warehouse/tests/test_stock_available_unreserved.py b/stock_by_warehouse/tests/test_stock_available_unreserved.py index 500ea136eae..7eef6e76ec4 100644 --- a/stock_by_warehouse/tests/test_stock_available_unreserved.py +++ b/stock_by_warehouse/tests/test_stock_available_unreserved.py @@ -142,7 +142,7 @@ def test01_stock_levels(self): self.compare_qty_available_not_res(product_a, 0) self.compare_qty_available_not_res(self.template_ab, 0) - picking_in_a.move_line_ids.write({"qty_done": 2}) + picking_in_a.move_line_ids.write({"quantity": 2, "picked": True}) picking_in_a.button_validate() self.compare_qty_available_not_res(product_a, 2) self.compare_qty_available_not_res(self.template_ab, 2) @@ -159,7 +159,7 @@ def test01_stock_levels(self): picking_in_b.action_confirm() picking_in_b.action_assign() - picking_in_b.move_line_ids.write({"qty_done": 3}) + picking_in_b.move_line_ids.write({"quantity": 3, "picked": True}) picking_in_b.button_validate() self.compare_qty_available_not_res(product_a, 2) self.compare_qty_available_not_res(product_b, 3) @@ -203,7 +203,7 @@ def test01_stock_levels(self): product.warehouses_stock_recompute = True self.assertEqual(safe_eval(product.warehouses_stock)["warehouse"], 3) - picking_out_a.move_line_ids.write({"qty_done": 2}) + picking_out_a.move_line_ids.write({"quantity": 2, "picked": True}) picking_out_a.button_validate() self.compare_qty_available_not_res(product_b, 1) self.compare_qty_available_not_res(self.template_ab, 3) diff --git a/stock_by_warehouse/views/product_product_views.xml b/stock_by_warehouse/views/product_product_views.xml index 01e2fe81807..e00ee9acf77 100644 --- a/stock_by_warehouse/views/product_product_views.xml +++ b/stock_by_warehouse/views/product_product_views.xml @@ -11,18 +11,18 @@ name="warehouses_stock" widget="warehouse" groups="stock.group_stock_multi_warehouses" - attrs="{'invisible': [('detailed_type', '!=', 'product')]}" + invisible="detailed_type != 'product'" />