mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Annotate BuildList queryset with integer cast of the reference
This commit is contained in:
parent
aa7eb3a6d0
commit
0cdc82a4b3
@ -10,7 +10,8 @@ from django.core.exceptions import ValidationError as DjangoValidationError
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from django.db.models import Case, When, Value
|
||||
from django.db.models import BooleanField
|
||||
from django.db.models import BooleanField, IntegerField
|
||||
from django.db.models.functions import Cast
|
||||
|
||||
from rest_framework import serializers
|
||||
from rest_framework.serializers import ValidationError
|
||||
@ -71,6 +72,11 @@ class BuildSerializer(InvenTreeModelSerializer):
|
||||
)
|
||||
)
|
||||
|
||||
# Annotate with a "integer" version of the reference field, to be used for natural sorting
|
||||
queryset = queryset.annotate(
|
||||
integer_ref=Cast('reference', output_field=IntegerField())
|
||||
)
|
||||
|
||||
return queryset
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user