Update serializer

This commit is contained in:
Oliver 2023-05-13 22:14:44 +10:00
parent c540004a60
commit 9ac82a93d5

View File

@ -20,6 +20,7 @@ from InvenTree.status_codes import StockStatus
from stock.models import StockItem, StockLocation from stock.models import StockItem, StockLocation
from stock.serializers import StockItemSerializerBrief, LocationSerializer from stock.serializers import StockItemSerializerBrief, LocationSerializer
import common.serializers
from part.models import BomItem from part.models import BomItem
from part.serializers import PartSerializer, PartBriefSerializer from part.serializers import PartSerializer, PartBriefSerializer
from users.serializers import OwnerSerializer from users.serializers import OwnerSerializer
@ -46,6 +47,8 @@ class BuildSerializer(InvenTreeModelSerializer):
'parent', 'parent',
'part', 'part',
'part_detail', 'part_detail',
'project_code',
'project_code_detail',
'overdue', 'overdue',
'reference', 'reference',
'sales_order', 'sales_order',
@ -87,6 +90,8 @@ class BuildSerializer(InvenTreeModelSerializer):
barcode_hash = serializers.CharField(read_only=True) barcode_hash = serializers.CharField(read_only=True)
project_code_detail = common.serializers.ProjectCodeSerializer(source='project_code', many=False, read_only=True)
@staticmethod @staticmethod
def annotate_queryset(queryset): def annotate_queryset(queryset):
"""Add custom annotations to the BuildSerializer queryset, performing database queries as efficiently as possible. """Add custom annotations to the BuildSerializer queryset, performing database queries as efficiently as possible.