From 4fbc2298510a0200c61814e83f81c5d2fc49653e 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 ae65a0c..24883e6 100644 --- a/product.py +++ b/product.py @@ -41,8 +41,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): @@ -54,8 +55,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):