From 292c381546d32ac2d8060aaeacaa9fd369812568 Mon Sep 17 00:00:00 2001 From: Maxime Richez Date: Tue, 10 Apr 2018 15:26:17 +0200 Subject: [PATCH] Replace products_ids by grouping_filter --- product.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/product.py b/product.py index 409553d..0f9d637 100644 --- a/product.py +++ b/product.py @@ -3,7 +3,6 @@ # the full copyright notices and license terms. from trytond.pool import Pool, PoolMeta from trytond.transaction import Transaction -from trytond.pyson import If, Eval, Less __all__ = ['Template', 'Product'] @@ -19,7 +18,8 @@ class Template: 'locations' not in Transaction().context): warehouses = Location.search([('type', '=', 'warehouse')]) location_ids = [w.storage_location.id for w in warehouses] - with Transaction().set_context(locations=location_ids, with_childs=True): + with Transaction().set_context(locations=location_ids, + with_childs=True): return super(Template, self).sum_product(name) return super(Template, self).sum_product(name) @@ -43,7 +43,9 @@ class Product: location_ids = [w.storage_location.id for w in warehouses] with Transaction().set_context(locations=location_ids, stock_date_end=today, with_childs=True): - return cls._get_quantity(products, name, location_ids, products) + products_ids = map(int, products) + return cls._get_quantity(products, name, location_ids, + grouping_filter=(products_ids,)) # return super (with locations in context) return super(Product, cls).get_quantity(products, name) @@ -59,7 +61,8 @@ class Product: 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, stock_date_end=today): + with Transaction().set_context(locations=location_ids, + stock_date_end=today): return cls._search_quantity(name, location_ids, domain) # return super (with locations in context) return super(Product, cls).search_quantity(name, domain)