mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Apply same fix to PurchaseOrder and SalesOrder lists
This commit is contained in:
parent
233672d822
commit
e46875b0a3
@ -34,8 +34,6 @@ class InvenTreeOrderingFilter(OrderingFilter):
|
|||||||
Ordering fields should be mapped to separate fields
|
Ordering fields should be mapped to separate fields
|
||||||
"""
|
"""
|
||||||
|
|
||||||
idx = 0
|
|
||||||
|
|
||||||
ordering_initial = ordering
|
ordering_initial = ordering
|
||||||
ordering = []
|
ordering = []
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class BuildSerializer(InvenTreeModelSerializer):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Annotate with a "integer" version of the reference field, to be used for natural sorting
|
# Annotate with an "integer" version of the reference field, to be used for natural sorting
|
||||||
queryset = queryset.annotate(
|
queryset = queryset.annotate(
|
||||||
integer_ref=Cast('reference', output_field=IntegerField())
|
integer_ref=Cast('reference', output_field=IntegerField())
|
||||||
)
|
)
|
||||||
|
@ -152,9 +152,13 @@ class POList(generics.ListCreateAPIView):
|
|||||||
filter_backends = [
|
filter_backends = [
|
||||||
rest_filters.DjangoFilterBackend,
|
rest_filters.DjangoFilterBackend,
|
||||||
filters.SearchFilter,
|
filters.SearchFilter,
|
||||||
filters.OrderingFilter,
|
InvenTreeOrderingFilter,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
ordering_field_aliases = {
|
||||||
|
'reference': ['integer_ref', 'reference'],
|
||||||
|
}
|
||||||
|
|
||||||
filter_fields = [
|
filter_fields = [
|
||||||
'supplier',
|
'supplier',
|
||||||
]
|
]
|
||||||
@ -504,9 +508,13 @@ class SOList(generics.ListCreateAPIView):
|
|||||||
filter_backends = [
|
filter_backends = [
|
||||||
rest_filters.DjangoFilterBackend,
|
rest_filters.DjangoFilterBackend,
|
||||||
filters.SearchFilter,
|
filters.SearchFilter,
|
||||||
filters.OrderingFilter,
|
InvenTreeOrderingFilter,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
ordering_field_aliases = {
|
||||||
|
'reference': ['integer_ref', 'reference'],
|
||||||
|
}
|
||||||
|
|
||||||
filter_fields = [
|
filter_fields = [
|
||||||
'customer',
|
'customer',
|
||||||
]
|
]
|
||||||
|
@ -4,6 +4,7 @@ JSON serializers for the Order API
|
|||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
from django.db.models.fields import IntegerField
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ from django.core.exceptions import ValidationError as DjangoValidationError
|
|||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.db.models import Case, When, Value
|
from django.db.models import Case, When, Value
|
||||||
from django.db.models import BooleanField, ExpressionWrapper, F
|
from django.db.models import BooleanField, ExpressionWrapper, F
|
||||||
|
from django.db.models.functions import Cast
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.serializers import ValidationError
|
from rest_framework.serializers import ValidationError
|
||||||
@ -73,6 +75,11 @@ class POSerializer(InvenTreeModelSerializer):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Annotate with an "integer" version of the reference field, to be used for natural sorting
|
||||||
|
queryset = queryset.annotate(
|
||||||
|
integer_ref=Cast('reference', output_field=IntegerField())
|
||||||
|
)
|
||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
supplier_detail = CompanyBriefSerializer(source='supplier', many=False, read_only=True)
|
supplier_detail = CompanyBriefSerializer(source='supplier', many=False, read_only=True)
|
||||||
@ -428,6 +435,11 @@ class SalesOrderSerializer(InvenTreeModelSerializer):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Annotate with an "integer" version of the reference field, to be used for natural sorting
|
||||||
|
queryset = queryset.annotate(
|
||||||
|
integer_ref=Cast('reference', output_field=IntegerField())
|
||||||
|
)
|
||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
customer_detail = CompanyBriefSerializer(source='customer', many=False, read_only=True)
|
customer_detail = CompanyBriefSerializer(source='customer', many=False, read_only=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user