mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add part_detail and location_detail to the StockItem detail class
This commit is contained in:
parent
fce26c80b7
commit
2530313e68
@ -59,6 +59,18 @@ class StockDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
serializer_class = StockItemSerializer
|
||||
permission_classes = (permissions.IsAuthenticated,)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
|
||||
part_detail = str2bool(self.request.GET.get('part_detail', False))
|
||||
loc_detail = str2bool(self.request.GET.get('location_detail', False))
|
||||
|
||||
kwargs['part_detail'] = part_detail
|
||||
kwargs['location_detail'] = loc_detail
|
||||
|
||||
kwargs['context'] = self.get_serializer_context()
|
||||
|
||||
return self.serializer_class(*args, **kwargs)
|
||||
|
||||
|
||||
class StockFilter(FilterSet):
|
||||
""" FilterSet for advanced stock filtering.
|
||||
|
@ -59,6 +59,8 @@ class StockItemSerializer(InvenTreeModelSerializer):
|
||||
|
||||
part_name = serializers.CharField(source='get_part_name', read_only=True)
|
||||
|
||||
part_image = serializers.CharField(source='part__image', read_only=True)
|
||||
|
||||
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
|
||||
location_detail = LocationBriefSerializer(source='location', many=False, read_only=True)
|
||||
|
||||
@ -81,8 +83,9 @@ class StockItemSerializer(InvenTreeModelSerializer):
|
||||
'pk',
|
||||
'url',
|
||||
'part',
|
||||
'part_name',
|
||||
'part_detail',
|
||||
'part_name',
|
||||
'part_image',
|
||||
'supplier_part',
|
||||
'location',
|
||||
'location_detail',
|
||||
|
Loading…
Reference in New Issue
Block a user