diff --git a/src/backend/InvenTree/stock/api.py b/src/backend/InvenTree/stock/api.py index 00119d1486..4e552ad445 100644 --- a/src/backend/InvenTree/stock/api.py +++ b/src/backend/InvenTree/stock/api.py @@ -1320,8 +1320,7 @@ class TestStatistics(GenericAPIView): ) def get(self, request, pk, *args, **kwargs): """Return test execution count matrix broken down by test result.""" - instance = self.get_object() - serializer = self.get_serializer(instance) + serializer = self.get_serializer(request.data) if request.resolver_match.url_name == 'api-test-statistics-by-part': serializer.context['type'] = 'by-part' elif request.resolver_match.url_name == 'api-test-statistics-by-build': diff --git a/src/backend/InvenTree/stock/serializers.py b/src/backend/InvenTree/stock/serializers.py index e92c133eb7..6f05d477c4 100644 --- a/src/backend/InvenTree/stock/serializers.py +++ b/src/backend/InvenTree/stock/serializers.py @@ -885,13 +885,15 @@ class TestStatisticsSerializer(serializers.Serializer): def to_representation(self, obj): """Just pass through the test statistics from the model.""" if self.context['type'] == 'by-part': - return obj.part_test_statistics( + return StockItemTestResult.part_test_statistics( + {}, self.context['pk'], self.context['finished_datetime_after'], self.context['finished_datetime_before'], ) elif self.context['type'] == 'by-build': - return obj.build_test_statistics( + return StockItemTestResult.build_test_statistics( + {}, self.context['pk'], self.context['finished_datetime_after'], self.context['finished_datetime_before'],