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
|
serializer_class = StockItemSerializer
|
||||||
permission_classes = (permissions.IsAuthenticated,)
|
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):
|
class StockFilter(FilterSet):
|
||||||
""" FilterSet for advanced stock filtering.
|
""" FilterSet for advanced stock filtering.
|
||||||
|
@ -59,6 +59,8 @@ class StockItemSerializer(InvenTreeModelSerializer):
|
|||||||
|
|
||||||
part_name = serializers.CharField(source='get_part_name', read_only=True)
|
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)
|
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
|
||||||
location_detail = LocationBriefSerializer(source='location', many=False, read_only=True)
|
location_detail = LocationBriefSerializer(source='location', many=False, read_only=True)
|
||||||
|
|
||||||
@ -81,8 +83,9 @@ class StockItemSerializer(InvenTreeModelSerializer):
|
|||||||
'pk',
|
'pk',
|
||||||
'url',
|
'url',
|
||||||
'part',
|
'part',
|
||||||
'part_name',
|
|
||||||
'part_detail',
|
'part_detail',
|
||||||
|
'part_name',
|
||||||
|
'part_image',
|
||||||
'supplier_part',
|
'supplier_part',
|
||||||
'location',
|
'location',
|
||||||
'location_detail',
|
'location_detail',
|
||||||
|
Loading…
Reference in New Issue
Block a user