From 477b8176c18fb0b88842646a7495ae9e8eb90aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Pigeon?= Date: Wed, 10 May 2017 12:24:52 +0200 Subject: [PATCH] [REF] stock: allow domain selection hook Add hook to allow override of domain in orderpoint scheduler. Closes #16909 opw-743020 --- addons/stock/models/procurement.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/stock/models/procurement.py b/addons/stock/models/procurement.py index 32f943a9f57..89cdde0c064 100644 --- a/addons/stock/models/procurement.py +++ b/addons/stock/models/procurement.py @@ -279,6 +279,11 @@ class ProcurementOrder(models.Model): def _procurement_from_orderpoint_post_process(self, orderpoint_ids): return True + def _get_orderpoint_domain(self, company_id=False): + domain = [('company_id', '=', company_id)] if company_id else [] + domain += [('product_id.active', '=', True)] + return domain + @api.model def _procure_orderpoint_confirm(self, use_new_cursor=False, company_id=False): """ Create procurements based on orderpoints. @@ -288,9 +293,7 @@ class ProcurementOrder(models.Model): """ OrderPoint = self.env['stock.warehouse.orderpoint'] - - domain = [('company_id', '=', company_id)] if company_id else [] - domain += [('product_id.active', '=', True)] + domain = self._get_orderpoint_domain(company_id=company_id) orderpoints_noprefetch = OrderPoint.with_context(prefetch_fields=False).search(domain, order=self._procurement_from_orderpoint_get_order()).ids while orderpoints_noprefetch: