mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds 'suppliers' field to Part serializer
- Number of supplier parts associated with the Part object
This commit is contained in:
parent
5d1e6981d8
commit
cf6a03456f
@ -245,6 +245,14 @@ class PartSerializer(InvenTreeModelSerializer):
|
||||
Decimal(0),
|
||||
)
|
||||
)
|
||||
|
||||
# Annotate with the number of 'suppliers'
|
||||
queryset = queryset.annotate(
|
||||
suppliers=Coalesce(
|
||||
SubqueryCount('supplier_parts'),
|
||||
Decimal(0),
|
||||
),
|
||||
)
|
||||
|
||||
return queryset
|
||||
|
||||
@ -263,6 +271,7 @@ class PartSerializer(InvenTreeModelSerializer):
|
||||
ordering = serializers.FloatField(read_only=True)
|
||||
building = serializers.FloatField(read_only=True)
|
||||
stock_item_count = serializers.IntegerField(read_only=True)
|
||||
suppliers = serializers.IntegerField(read_only=True)
|
||||
|
||||
image = serializers.CharField(source='get_image_url', read_only=True)
|
||||
thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True)
|
||||
@ -308,6 +317,7 @@ class PartSerializer(InvenTreeModelSerializer):
|
||||
'salable',
|
||||
'starred',
|
||||
'stock_item_count',
|
||||
'suppliers',
|
||||
'thumbnail',
|
||||
'trackable',
|
||||
'units',
|
||||
|
Loading…
Reference in New Issue
Block a user