diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 0d257e606b..aad36cc3dc 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -698,6 +698,11 @@ class StockItemTestResultList(generics.ListCreateAPIView): except: pass + try: + kwargs['attachment_detail'] = str2bool(self.request.query_params.get('attachment_detail', False)) + except: + pass + kwargs['context'] = self.get_serializer_context() return self.serializer_class(*args, **kwargs) diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 5c33750fde..865a63a2c2 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -222,15 +222,20 @@ class StockItemTestResultSerializer(InvenTreeModelSerializer): """ Serializer for the StockItemTestResult model """ user_detail = UserSerializerBrief(source='user', read_only=True) + attachment_detail = StockItemAttachmentSerializer(source='attachment', read_only=True) def __init__(self, *args, **kwargs): user_detail = kwargs.pop('user_detail', False) + attachment_detail = kwargs.pop('attachment_detail', False) super().__init__(*args, **kwargs) if user_detail is not True: self.fields.pop('user_detail') + if attachment_detail is not True: + self.fields.pop('attachment_detail') + class Meta: model = StockItemTestResult @@ -241,6 +246,7 @@ class StockItemTestResultSerializer(InvenTreeModelSerializer): 'result', 'value', 'attachment', + 'attachment_detail', 'notes', 'user', 'user_detail',