Update serializers for Order model

This commit is contained in:
Oliver Walters 2020-09-05 23:08:59 +10:00
parent 598e15af46
commit 5f2e4c3790

View File

@ -7,7 +7,7 @@ from __future__ import unicode_literals
from rest_framework import serializers
from django.db.models import Count
from sql_util.utils import SubqueryCount
from InvenTree.serializers import InvenTreeModelSerializer
from InvenTree.serializers import InvenTreeAttachmentSerializerField
@ -39,10 +39,12 @@ class POSerializer(InvenTreeModelSerializer):
Add extra information to the queryset
"""
return queryset.annotate(
line_items=Count('lines'),
queryset = queryset.annotate(
line_items=SubqueryCount('lines')
)
return queryset
supplier_detail = CompanyBriefSerializer(source='supplier', many=False, read_only=True)
line_items = serializers.IntegerField(read_only=True)
@ -147,10 +149,12 @@ class SalesOrderSerializer(InvenTreeModelSerializer):
Add extra information to the queryset
"""
return queryset.annotate(
line_items=Count('lines'),
queryset = queryset.annotate(
line_items=SubqueryCount('lines')
)
return queryset
customer_detail = CompanyBriefSerializer(source='customer', many=False, read_only=True)
line_items = serializers.IntegerField(read_only=True)