2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-05-17 14:58:36 +00:00

Update schema to match server responses for SelectionList and TreePath (#11948)

* Annotate default list selection to allow nullable and ensure entry_count is never null

* Add icon (nullable) to TreePath schema

* Bump api version
This commit is contained in:
Joe Rogers
2026-05-15 15:24:39 +02:00
committed by GitHub
parent d6f257dc58
commit 7655dc3819
4 changed files with 14 additions and 3 deletions
@@ -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
@@ -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):
+4
View File
@@ -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."""
+1 -1
View File
@@ -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)