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: