Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
21e4370
Lazy evaluation of optional serializer fields
SchrodingersGat Jan 1, 2026
5a166f8
Refactor BuildLineSerializer class
SchrodingersGat Jan 1, 2026
f798307
Simplify gathering
SchrodingersGat Jan 1, 2026
b397ab9
Refactor BuildSerializer
SchrodingersGat Jan 1, 2026
09d35d2
Refactor other Build serializers
SchrodingersGat Jan 1, 2026
8f47288
Refactor Part serializers
SchrodingersGat Jan 1, 2026
70489cd
Refactoring more serializers to use OptionalField
SchrodingersGat Jan 1, 2026
25dd239
More refactoring
SchrodingersGat Jan 1, 2026
e71268a
Cleanup for mixin class
SchrodingersGat Jan 1, 2026
34a7474
Ensure any optional fields we added in are not missed
SchrodingersGat Jan 1, 2026
dcf6a55
Fixes
SchrodingersGat Jan 1, 2026
31c21a5
Rehydrate optional fields for metadata
SchrodingersGat Jan 1, 2026
b62a89a
Add TreePathSerializer class
SchrodingersGat Jan 1, 2026
fc6bb24
Further improvements:
SchrodingersGat Jan 2, 2026
6ad980a
Adjust unit tests
SchrodingersGat Jan 2, 2026
9e46356
Fix for "build_relational_field"
SchrodingersGat Jan 2, 2026
cddf922
Fix case where multiple fields can share same filter
SchrodingersGat Jan 2, 2026
61251f4
additional unit tests
SchrodingersGat Jan 2, 2026
0386a6a
Bump API version
SchrodingersGat Jan 2, 2026
b18a3e3
Remove top-level detection
SchrodingersGat Jan 2, 2026
ea049ab
Cache serializer to prevent multiple __init__ calls
SchrodingersGat Jan 2, 2026
4785f79
Revert caching change
SchrodingersGat Jan 2, 2026
7123efc
Simplify field removal
SchrodingersGat Jan 2, 2026
95e0aa8
Adjust unit test
SchrodingersGat Jan 2, 2026
a18dffe
Remove docstring comment which is no longer true
SchrodingersGat Jan 3, 2026
30f7760
Merge branch 'master' into filter-refactor
SchrodingersGat Jan 3, 2026
cae2644
Ensure read-only fields are skipped for data import
SchrodingersGat Jan 3, 2026
8e77006
Use SAFE_METHODS
SchrodingersGat Jan 3, 2026
853726e
Do not convert to lowercase
SchrodingersGat Jan 3, 2026
61afb97
Updated docstring
SchrodingersGat Jan 4, 2026
fa3f080
Remove FilterableSerializerField mixin
SchrodingersGat Jan 4, 2026
4bbd3dd
Merge branch 'master' into filter-refactor
SchrodingersGat Jan 4, 2026
4244367
Ensure all fields are returned when generating schema
SchrodingersGat Jan 4, 2026
eb8ce92
Fix order of operations
SchrodingersGat Jan 4, 2026
f8cab0e
Merge branch 'master' into filter-refactor
matmair Jan 6, 2026
3793a75
Merge commit 'e1b5fbd38da3b6e7e96272532278fa9f52da5e69' into filter-r…
SchrodingersGat Jan 10, 2026
d07a77d
Add assertion to unit test
SchrodingersGat Jan 10, 2026
e84b50e
Merge branch 'master' into filter-refactor
matmair Jan 14, 2026
e688e4c
Merge branch 'master' into filter-refactor
matmair Jan 16, 2026
65b944e
Merge branch 'master' into filter-refactor
matmair Jan 16, 2026
e75ebd4
Merge branch 'master' into filter-refactor
SchrodingersGat Jan 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/backend/InvenTree/InvenTree/api_version.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
"""InvenTree API version information."""

# InvenTree API version
INVENTREE_API_VERSION = 440
INVENTREE_API_VERSION = 441
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""

INVENTREE_API_TEXT = """

v441 -> 2026-01-16 : https://github.com/inventree/InvenTree/pull/11073
- Add OptionalField class for cleaner handling of optional fields in serializers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be other API changes too, should they also be mentioned?


v440 -> 2026-01-15 : https://github.com/inventree/InvenTree/pull/10796
- Adds confirm and confirm_text to all settings

Expand Down
9 changes: 9 additions & 0 deletions src/backend/InvenTree/InvenTree/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@ def get_field_info(self, field):

We take the regular DRF metadata and add our own unique flavor
"""
from InvenTree.serializers import OptionalField

if isinstance(field, OptionalField) or issubclass(
field.__class__, OptionalField
):
# Rehydrate the OptionalField for proper introspection
rehydrated_field = field.serializer_class(**(field.serializer_kwargs or {}))
return self.get_field_info(rehydrated_field)

# Try to add the child property to the dependent field to be used by the super call
if self.label_lookup[field] == 'dependent field':
field.get_child(raise_exception=True)
Expand Down
30 changes: 1 addition & 29 deletions src/backend/InvenTree/InvenTree/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from rest_framework.response import Response

import data_exporter.mixins
import data_exporter.serializers
import importer.mixins
from InvenTree.fields import InvenTreeNotesField, OutputConfiguration
from InvenTree.helpers import (
Expand Down Expand Up @@ -223,20 +222,6 @@ def __init_subclass__(cls, **kwargs):
if getattr(cls, 'output_options', None) is not None:
schema_for_view_output_options(cls)

def __init__(self) -> None:
"""Initialize the mixin. Check that the serializer is compatible."""
super().__init__()

# Check that the serializer was defined
if (
hasattr(self, 'serializer_class')
and isinstance(self.serializer_class, type)
and (not issubclass(self.serializer_class, FilterableSerializerMixin))
):
raise Exception(
'INVE-I2: `OutputOptionsMixin` can only be used with serializers that contain the `FilterableSerializerMixin` mixin'
)

def get_serializer(self, *args, **kwargs):
"""Return serializer instance with output options applied."""
request = getattr(self, 'request', None)
Expand All @@ -250,20 +235,7 @@ def get_serializer(self, *args, **kwargs):
context['request'] = request
kwargs['context'] = context

serializer = super().get_serializer(*args, **kwargs)

# Check if the serializer actually can be filtered - makes not much sense to use this mixin without that prerequisite
if isinstance(
serializer, data_exporter.serializers.DataExportOptionsSerializer
):
# Skip in this instance, special case for determining export options
pass
elif not isinstance(serializer, FilterableSerializerMixin):
raise Exception(
'INVE-I2: `OutputOptionsMixin` can only be used with serializers that contain the `FilterableSerializerMixin` mixin'
)

return serializer
return super().get_serializer(*args, **kwargs)

def get_queryset(self):
"""Return the queryset with output options applied.
Expand Down
Loading
Loading