diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 7623b84cd32..83e80f2de12 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -3068,8 +3068,18 @@ class stock_warehouse(osv.osv): def _location_used(self, cr, uid, location_id, warehouse, context=None): pull_obj = self.pool['procurement.rule'] push_obj = self.pool['stock.location.path'] - pulls = pull_obj.search(cr, uid, ['&', ('route_id', 'not in', [x.id for x in warehouse.route_ids]), '|', ('location_src_id', '=', location_id), ('location_id', '=', location_id)], context=context) - pushs = push_obj.search(cr, uid, ['&', ('route_id', 'not in', [x.id for x in warehouse.route_ids]), '|', ('location_from_id', '=', location_id), ('location_dest_id', '=', location_id)], context=context) + + domain = ['&', ('route_id', 'not in', [x.id for x in warehouse.route_ids]), + '|', ('location_src_id', '=', location_id), # noqa + ('location_id', '=', location_id) + ] + pulls = pull_obj.search_count(cr, uid, domain, context=context) + + domain = ['&', ('route_id', 'not in', [x.id for x in warehouse.route_ids]), + '|', ('location_from_id', '=', location_id), # noqa + ('location_dest_id', '=', location_id) + ] + pushs = push_obj.search_count(cr, uid, domain, context=context) if pulls or pushs: return True return False