From ba2012826fda1510f7c920ca0ea46063162cbc0c Mon Sep 17 00:00:00 2001 From: Bruno Zanotti Date: Fri, 19 Jan 2024 15:54:41 -0300 Subject: [PATCH] [IMP] stock: allow to filter orderpoint locations This commit allow to inherit the method _get_orderpoint_locations to filter in which location compute orderpoints imrpoving performance and usability closes odoo/odoo#151909 X-original-commit: 2f245b40e8cecf87cb3334a80b24a54cd6e99d12 Signed-off-by: William Henrotin (whe) --- addons/stock/models/stock_orderpoint.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_orderpoint.py b/addons/stock/models/stock_orderpoint.py index c975fd4b2c4..28890671c27 100644 --- a/addons/stock/models/stock_orderpoint.py +++ b/addons/stock/models/stock_orderpoint.py @@ -345,7 +345,7 @@ class StockWarehouseOrderpoint(models.Model): orderpoints = orderpoints - orderpoints_removed to_refill = defaultdict(float) all_product_ids = self._get_orderpoint_products() - all_replenish_location_ids = self.env['stock.location'].search([('replenish_location', '=', True)]) + all_replenish_location_ids = self._get_orderpoint_locations() ploc_per_day = defaultdict(set) # For each replenish location get products with negative virtual_available aka forecast for loc in all_replenish_location_ids: @@ -585,3 +585,6 @@ class StockWarehouseOrderpoint(models.Model): def _get_orderpoint_products(self): return self.env['product.product'].search([('type', '=', 'product'), ('stock_move_ids', '!=', False)]) + + def _get_orderpoint_locations(self): + return self.env['stock.location'].search([('replenish_location', '=', True)])