mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Update serializers for Order model
This commit is contained in:
parent
598e15af46
commit
5f2e4c3790
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user