mirror of
https://github.com/inventree/InvenTree.git
synced 2026-05-17 23:08:28 +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:
@@ -1,11 +1,15 @@
|
|||||||
"""InvenTree API version information."""
|
"""InvenTree API version information."""
|
||||||
|
|
||||||
# InvenTree API version
|
# 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."""
|
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||||
|
|
||||||
INVENTREE_API_TEXT = """
|
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
|
v486 -> 2026-05-10 : https://github.com/inventree/InvenTree/pull/11914
|
||||||
- Adds "maximum_stock" field to the Part model and associated API endpoints
|
- 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
|
- 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 [])]
|
allowed_fields = ['pk', 'name', *(extra_fields or [])]
|
||||||
|
|
||||||
|
if InvenTree.ready.isGeneratingSchema():
|
||||||
|
return
|
||||||
|
|
||||||
for field in list(self.fields.keys()):
|
for field in list(self.fields.keys()):
|
||||||
if field not in allowed_fields:
|
if field not in allowed_fields:
|
||||||
self.fields.pop(field, None)
|
self.fields.pop(field, None)
|
||||||
|
|
||||||
pk = serializers.IntegerField(read_only=True)
|
pk = serializers.IntegerField(read_only=True)
|
||||||
name = serializers.CharField(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):
|
class InvenTreeMoneySerializer(MoneyField):
|
||||||
|
|||||||
@@ -1145,6 +1145,10 @@ class SelectionListDetail(RetrieveUpdateDestroyAPI):
|
|||||||
serializer_class = common.serializers.SelectionListSerializer
|
serializer_class = common.serializers.SelectionListSerializer
|
||||||
permission_classes = [IsAuthenticatedOrReadScope]
|
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:
|
class EntryMixin:
|
||||||
"""Mixin for SelectionEntry views."""
|
"""Mixin for SelectionEntry views."""
|
||||||
|
|||||||
@@ -995,7 +995,7 @@ class SelectionListSerializer(InvenTreeModelSerializer):
|
|||||||
'entry_count',
|
'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)
|
choices = SelectionEntrySerializer(source='entries', many=True, required=False)
|
||||||
entry_count = serializers.IntegerField(read_only=True)
|
entry_count = serializers.IntegerField(read_only=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user