mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Make 'part_detail' field in SupplierPart serializer optional
This commit is contained in:
@ -11,6 +11,8 @@ from rest_framework import generics, permissions
|
||||
|
||||
from django.conf.urls import url, include
|
||||
|
||||
from InvenTree.helpers import str2bool
|
||||
|
||||
from .models import Company
|
||||
from .models import SupplierPart, SupplierPriceBreak
|
||||
|
||||
@ -84,6 +86,16 @@ class SupplierPartList(generics.ListCreateAPIView):
|
||||
'supplier',
|
||||
'pricebreaks')
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
|
||||
# Do we wish to include extra detail?
|
||||
part_detail = str2bool(self.request.GET.get('part_detail', None))
|
||||
|
||||
kwargs['part_detail'] = part_detail
|
||||
kwargs['context'] = self.get_serializer_context()
|
||||
|
||||
return self.serializer_class(*args, **kwargs)
|
||||
|
||||
serializer_class = SupplierPartSerializer
|
||||
|
||||
permission_classes = [
|
||||
|
Reference in New Issue
Block a user