trytond-patches/issue239_630.diff

32 lines
1.2 KiB
Diff

diff -r a0ccc84aaa24 location.py
--- a/trytond/trytond/modules/stock/location.py Mon Oct 20 15:08:22 2014 +0200
+++ b/trytond/trytond/modules/stock/location.py Mon Nov 03 13:36:23 2014 +0100
@@ -161,6 +161,11 @@
return [(cls._rec_name,) + tuple(clause[1:])]
@classmethod
+ def _quantity_grouping_and_key(cls):
+ product_id = Transaction().context['product']
+ return ('product', ), (product_id,)
+
+ @classmethod
def get_quantity(cls, locations, name):
pool = Pool()
Product = pool.get('product.product')
@@ -192,12 +197,13 @@
pbl = {}
for sub_locations in grouped_slice(locations):
location_ids = [l.id for l in sub_locations]
+ grouping, key = cls._quantity_grouping_and_key()
with Transaction().set_context(context):
pbl.update(Product.products_by_location(
location_ids=location_ids, product_ids=[product_id],
- with_childs=True))
+ with_childs=True, grouping=grouping))
- return dict((loc.id, pbl.get((loc.id, product_id), 0))
+ return dict((loc.id, pbl.get((loc.id,) + key, 0))
for loc in locations)
@classmethod