From d2befe114ee106c9247d51376c84cd8826307158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 3 Apr 2018 16:40:00 +0200 Subject: [PATCH] Do not include flat location children from child_of search If the flat location children are not explicitly in the requested locations, they should not be included because the quantity is already included in the parent location and they will be added twice if a single location is requested (because of the quick loop). issue7162 review44871003 --- move.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/move.py b/move.py index b1a70a6789..e590b125d8 100644 --- a/move.py +++ b/move.py @@ -1469,8 +1469,11 @@ def _location_children(location_ids, query=False): nested_location_ids.append(location.id) if nested_location_ids: return Location.search(['OR', - ('parent', 'child_of', nested_location_ids), - ('id', 'in', flat_location_ids), + [ + ('parent', 'child_of', nested_location_ids), + ('parent.flat_childs', '!=', True), + ], + ('id', 'in', location_ids), ], query=query, order=[]) else: if query: