From b0f60210025d41f13c3cc5f11e0fc3841af7eb25 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 18 Apr 2023 22:40:31 +1000 Subject: [PATCH] Implement pagination for stock history tracking API (#4629) --- InvenTree/stock/api.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index f9b784a46c..b54f311142 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -1188,7 +1188,12 @@ class StockTrackingList(ListAPI): """List all stock tracking entries.""" queryset = self.filter_queryset(self.get_queryset()) - serializer = self.get_serializer(queryset, many=True) + page = self.paginate_queryset(queryset) + + if page is not None: + serializer = self.get_serializer(page, many=True) + else: + serializer = self.get_serializer(queryset, many=True) data = serializer.data @@ -1262,6 +1267,8 @@ class StockTrackingList(ListAPI): except Exception: pass + if page is not None: + return self.get_paginated_response(data) if request.is_ajax(): return JsonResponse(data, safe=False) else: