From 38c3be4396ae4661b140137a46eff2335583bd41 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Sat, 18 Oct 2025 18:41:36 +0200 Subject: [PATCH] make check more robust --- src/backend/InvenTree/InvenTree/mixins.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/InvenTree/InvenTree/mixins.py b/src/backend/InvenTree/InvenTree/mixins.py index 756672ebd2..cd5f492175 100644 --- a/src/backend/InvenTree/InvenTree/mixins.py +++ b/src/backend/InvenTree/InvenTree/mixins.py @@ -222,6 +222,18 @@ class OutputOptionsMixin: 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 ( + 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.""" if self.output_options and hasattr(self, 'request'):