diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 9179805ed8..f8f20a96b1 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -76,6 +76,9 @@ class TreeSerializer(views.APIView): top_count = 0 + # Construct the top-level items + top_items = [i for i in items if i.parent is None] + for item in top_items: nodes.append(self.itemToJson(item)) top_count += item.item_count