diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index f9e89d5712..a25ba5d0b9 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -1,11 +1,15 @@ """InvenTree API version information.""" # InvenTree API version -INVENTREE_API_VERSION = 486 +INVENTREE_API_VERSION = 487 """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" INVENTREE_API_TEXT = """ +v487 -> 2026-05-15 : https://github.com/inventree/InvenTree/pull/11948 + - Make SelectionList default nullable + - Add icon to TreePath schema + v486 -> 2026-05-10 : https://github.com/inventree/InvenTree/pull/11914 - Adds "maximum_stock" field to the Part model and associated API endpoints - Adds "high_stock" filter to the Part API endpoint to filter parts which are above their maximum stock level diff --git a/src/backend/InvenTree/InvenTree/serializers.py b/src/backend/InvenTree/InvenTree/serializers.py index b739143b8a..7e0216ef38 100644 --- a/src/backend/InvenTree/InvenTree/serializers.py +++ b/src/backend/InvenTree/InvenTree/serializers.py @@ -315,13 +315,16 @@ class TreePathSerializer(serializers.Serializer): allowed_fields = ['pk', 'name', *(extra_fields or [])] + if InvenTree.ready.isGeneratingSchema(): + return + for field in list(self.fields.keys()): if field not in allowed_fields: self.fields.pop(field, None) pk = serializers.IntegerField(read_only=True) name = serializers.CharField(read_only=True) - icon = serializers.CharField(required=False, read_only=True) + icon = serializers.CharField(required=False, read_only=True, allow_null=True) class InvenTreeMoneySerializer(MoneyField): diff --git a/src/backend/InvenTree/common/api.py b/src/backend/InvenTree/common/api.py index f4d2cd671c..124961efe9 100644 --- a/src/backend/InvenTree/common/api.py +++ b/src/backend/InvenTree/common/api.py @@ -1145,6 +1145,10 @@ class SelectionListDetail(RetrieveUpdateDestroyAPI): serializer_class = common.serializers.SelectionListSerializer permission_classes = [IsAuthenticatedOrReadScope] + def get_queryset(self): + """Override the queryset method to include entry count.""" + return self.serializer_class.annotate_queryset(super().get_queryset()) + class EntryMixin: """Mixin for SelectionEntry views.""" diff --git a/src/backend/InvenTree/common/serializers.py b/src/backend/InvenTree/common/serializers.py index f8041a0a82..9a4175b9b4 100644 --- a/src/backend/InvenTree/common/serializers.py +++ b/src/backend/InvenTree/common/serializers.py @@ -995,7 +995,7 @@ class SelectionListSerializer(InvenTreeModelSerializer): 'entry_count', ] - default = SelectionEntrySerializer(read_only=True, many=False) + default = SelectionEntrySerializer(read_only=True, allow_null=True, many=False) choices = SelectionEntrySerializer(source='entries', many=True, required=False) entry_count = serializers.IntegerField(read_only=True)