Add ability to create a new supplierpart from the API

This commit is contained in:
Oliver Walters 2019-04-26 00:06:35 +10:00
parent 907bccf748
commit 9b4e86f36a
2 changed files with 6 additions and 3 deletions

View File

@ -146,7 +146,7 @@ class BomList(generics.ListAPIView):
] ]
class SupplierPartList(generics.ListAPIView): class SupplierPartList(generics.ListCreateAPIView):
queryset = SupplierPart.objects.all() queryset = SupplierPart.objects.all()
serializer_class = SupplierPartSerializer serializer_class = SupplierPartSerializer

View File

@ -90,8 +90,9 @@ class SupplierPartSerializer(serializers.ModelSerializer):
url = serializers.CharField(source='get_absolute_url', read_only=True) url = serializers.CharField(source='get_absolute_url', read_only=True)
part = PartBriefSerializer(many=False, read_only=True) part_name = serializers.CharField(source='part.name', read_only=True)
supplier = CompanyBriefSerializer(many=False, read_only=True)
supplier_name = serializers.CharField(source='supplier.name', read_only=True)
class Meta: class Meta:
model = SupplierPart model = SupplierPart
@ -99,7 +100,9 @@ class SupplierPartSerializer(serializers.ModelSerializer):
'pk', 'pk',
'url', 'url',
'part', 'part',
'part_name',
'supplier', 'supplier',
'supplier_name',
'SKU', 'SKU',
'manufacturer', 'manufacturer',
'MPN', 'MPN',