[IMP] stock: speed up _location_used method.
This commit is contained in:
+12
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user