From e71b1a27c0bd41d0dc1fed2af518b6d0c4f73c40 Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Thu, 7 Mar 2024 12:40:01 +0000 Subject: [PATCH] [FIX] stock: wrong sublocation condition to compute new orderpoints The condition to decide which moves to consider to create new orderpoints is incorrect. For example any move from a location that is sublocation of the main warehouse location should be considered as a out move. The inverse condition doesn't make much sense. closes odoo/odoo#157459 X-original-commit: 7c123a5c1d8ed8bf856d4701a972f59737323646 Signed-off-by: William Henrotin (whe) --- addons/stock/models/stock_orderpoint.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/models/stock_orderpoint.py b/addons/stock/models/stock_orderpoint.py index 4c8e1a5a7f5..d9a523893b1 100644 --- a/addons/stock/models/stock_orderpoint.py +++ b/addons/stock/models/stock_orderpoint.py @@ -377,9 +377,9 @@ class StockWarehouseOrderpoint(models.Model): path = {loc: loc.parent_path for loc in self.env['stock.location'].with_context(active_test=False).search([('id', 'child_of', all_replenish_location_ids.ids)])} for loc in all_replenish_location_ids: for product in all_product_ids: - qty_available = sum(q[1] for q in quants.get(product, [(0, 0)]) if q[0] and path[q[0]] in loc.parent_path) - incoming_qty = sum(m[1] for m in moves_in.get(product, [(0, 0)]) if m[0] and path[m[0]] in loc.parent_path) - outgoing_qty = sum(m[1] for m in moves_out.get(product, [(0, 0)]) if m[0] and path[m[0]] in loc.parent_path) + qty_available = sum(q[1] for q in quants.get(product, [(0, 0)]) if q[0] and loc.parent_path in path[q[0]]) + incoming_qty = sum(m[1] for m in moves_in.get(product, [(0, 0)]) if m[0] and loc.parent_path in path[m[0]]) + outgoing_qty = sum(m[1] for m in moves_out.get(product, [(0, 0)]) if m[0] and loc.parent_path in path[m[0]]) if float_compare(qty_available + incoming_qty - outgoing_qty, 0, precision_rounding=rounding[product.id]) < 0: # group product by lead_days and location in order to read virtual_available # in batch