From a3e89c98910474f8e46bf50d4014ba781ce1a63f Mon Sep 17 00:00:00 2001 From: resteve Date: Wed, 16 Sep 2015 16:00:03 +0200 Subject: [PATCH] Get locations in context --- product.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/product.py b/product.py index 5e7cbd5..657820a 100644 --- a/product.py +++ b/product.py @@ -30,8 +30,9 @@ class Product: def get_quantity(cls, products, name): Location = Pool().get('stock.location') + context = Transaction().context # not locations in context - if 'locations' not in Transaction().context: + if not context.get('locations'): warehouses = Location.search([('type', '=', 'warehouse')]) location_ids = [w.storage_location.id for w in warehouses] with Transaction().set_context(locations=location_ids): @@ -43,8 +44,9 @@ class Product: def search_quantity(cls, name, domain=None): Location = Pool().get('stock.location') + context = Transaction().context # not locations in context - if 'locations' not in Transaction().context: + if not context.get('locations'): warehouses = Location.search([('type', '=', 'warehouse')]) location_ids = [w.storage_location.id for w in warehouses] with Transaction().set_context(locations=location_ids):