mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-14 21:22:20 +00:00
Fill in last missing return types in schema (#10532)
* Add background task overview return type to schema * Implement serializer so schema generates correctly * Bump api version
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
"""InvenTree API version information."""
|
||||
|
||||
# InvenTree API version
|
||||
INVENTREE_API_VERSION = 405
|
||||
INVENTREE_API_VERSION = 406
|
||||
|
||||
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||
|
||||
INVENTREE_API_TEXT = """
|
||||
|
||||
v406 -> 2025-10-08: https://github.com/inventree/InvenTree/pull/10532
|
||||
- Set return type for background task overview
|
||||
- Implement serializer for part serial number detail
|
||||
|
||||
v405 -> 2025-10-07: https://github.com/inventree/InvenTree/pull/10530
|
||||
- Add response to generic/status endpoint
|
||||
- Fix logic for generic status model lookup to allow searching by class name string
|
||||
|
@@ -557,6 +557,7 @@ class BackgroundTaskOverview(APIView):
|
||||
permission_classes = [IsAuthenticatedOrReadScope, IsAdminUser]
|
||||
serializer_class = None
|
||||
|
||||
@extend_schema(responses={200: common.serializers.TaskOverviewSerializer})
|
||||
def get(self, request, fmt=None):
|
||||
"""Return information about the current status of the background task queue."""
|
||||
import django_q.models as q_models
|
||||
|
@@ -46,7 +46,6 @@ from InvenTree.mixins import (
|
||||
SerializerContextMixin,
|
||||
UpdateAPI,
|
||||
)
|
||||
from InvenTree.serializers import EmptySerializer
|
||||
from stock.models import StockLocation
|
||||
|
||||
from . import serializers as part_serializers
|
||||
@@ -594,19 +593,7 @@ class PartSerialNumberDetail(RetrieveAPI):
|
||||
"""API endpoint for returning extra serial number information about a particular part."""
|
||||
|
||||
queryset = Part.objects.all()
|
||||
serializer_class = EmptySerializer
|
||||
|
||||
def retrieve(self, request, *args, **kwargs):
|
||||
"""Return serial number information for the referenced Part instance."""
|
||||
part = self.get_object()
|
||||
|
||||
# Calculate the "latest" serial number
|
||||
latest_serial = part.get_latest_serial_number()
|
||||
next_serial = part.get_next_serial_number()
|
||||
|
||||
data = {'latest': latest_serial, 'next': next_serial}
|
||||
|
||||
return Response(data)
|
||||
serializer_class = part_serializers.PartSerialNumberSerializer
|
||||
|
||||
|
||||
class PartCopyBOM(CreateAPI):
|
||||
|
@@ -1548,6 +1548,21 @@ class PartPricingSerializer(InvenTree.serializers.InvenTreeModelSerializer):
|
||||
pricing.update_pricing()
|
||||
|
||||
|
||||
class PartSerialNumberSerializer(InvenTree.serializers.InvenTreeModelSerializer):
|
||||
"""Serializer for Part serial number information."""
|
||||
|
||||
class Meta:
|
||||
"""Metaclass defining serializer fields."""
|
||||
|
||||
model = Part
|
||||
fields = ['latest', 'next']
|
||||
|
||||
latest = serializers.CharField(
|
||||
source='get_latest_serial_number', read_only=True, allow_null=True
|
||||
)
|
||||
next = serializers.CharField(source='get_next_serial_number', read_only=True)
|
||||
|
||||
|
||||
class PartRelationSerializer(InvenTree.serializers.InvenTreeModelSerializer):
|
||||
"""Serializer for a PartRelated model."""
|
||||
|
||||
|
Reference in New Issue
Block a user