mirror of
https://github.com/NaN-tic/trytond-product_qty.git
synced 2023-12-13 21:20:11 +01:00
Get locations in context
This commit is contained in:
parent
07ebf02a5f
commit
4fbc229851
|
@ -41,8 +41,9 @@ class Product:
|
||||||
def get_quantity(cls, products, name):
|
def get_quantity(cls, products, name):
|
||||||
Location = Pool().get('stock.location')
|
Location = Pool().get('stock.location')
|
||||||
|
|
||||||
|
context = Transaction().context
|
||||||
# not locations in context
|
# not locations in context
|
||||||
if 'locations' not in Transaction().context:
|
if not context.get('locations'):
|
||||||
warehouses = Location.search([('type', '=', 'warehouse')])
|
warehouses = Location.search([('type', '=', 'warehouse')])
|
||||||
location_ids = [w.storage_location.id for w in warehouses]
|
location_ids = [w.storage_location.id for w in warehouses]
|
||||||
with Transaction().set_context(locations=location_ids):
|
with Transaction().set_context(locations=location_ids):
|
||||||
|
@ -54,8 +55,9 @@ class Product:
|
||||||
def search_quantity(cls, name, domain=None):
|
def search_quantity(cls, name, domain=None):
|
||||||
Location = Pool().get('stock.location')
|
Location = Pool().get('stock.location')
|
||||||
|
|
||||||
|
context = Transaction().context
|
||||||
# not locations in context
|
# not locations in context
|
||||||
if 'locations' not in Transaction().context:
|
if not context.get('locations'):
|
||||||
warehouses = Location.search([('type', '=', 'warehouse')])
|
warehouses = Location.search([('type', '=', 'warehouse')])
|
||||||
location_ids = [w.storage_location.id for w in warehouses]
|
location_ids = [w.storage_location.id for w in warehouses]
|
||||||
with Transaction().set_context(locations=location_ids):
|
with Transaction().set_context(locations=location_ids):
|
||||||
|
|
Loading…
Reference in a new issue