[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) <whe@odoo.com>
This commit is contained in:
Bruno Zanotti
2024-01-31 17:13:53 +00:00
parent 9891156c3b
commit ba2012826f
+4 -1
View File
@@ -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)])