From c4aab47e5e02b7a67426d5e7051da2f11d2ad140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 15 Oct 2012 23:16:29 +0200 Subject: [PATCH] Fix parent quantities computation issue2694 review558002 (transplanted from dc80f77b1c9448a40031a1bbd7c5111d7953da72) --- product.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/product.py b/product.py index fdd5f4ffa1..0abfb8dc89 100644 --- a/product.py +++ b/product.py @@ -478,16 +478,21 @@ class Product(ModelSQL, ModelView): if location.parent.id in leafs: leafs.remove(location.parent.id) parent[location.id] = location.parent.id - + locations = set((l.id for l in locations)) while leafs: - next_leafs = set() for l in leafs: + locations.remove(l) if l not in parent: continue - next_leafs.add(parent[l]) for product in res_product_ids: res.setdefault((parent[l], product), 0) res[(parent[l], product)] += res.get((l,product), 0) + next_leafs = set(locations) + for l in locations: + if l not in parent: + continue + if parent[l] in next_leafs and parent[l] in locations: + next_leafs.remove(parent[l]) leafs = next_leafs # clean result