From 5061e6b935caa4eb7e9f1610e8e22121035ebf80 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 2 Jul 2026 12:18:46 +0000 Subject: [PATCH] Dynamic class typing --- src/backend/InvenTree/InvenTree/serializers.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/serializers.py b/src/backend/InvenTree/InvenTree/serializers.py index d8a77b3d25..a187d73e51 100644 --- a/src/backend/InvenTree/InvenTree/serializers.py +++ b/src/backend/InvenTree/InvenTree/serializers.py @@ -963,9 +963,6 @@ class DuplicateOptionsSerializer(serializers.Serializer): Arguments: queryset: Queryset used for the `original` PrimaryKeyRelatedField. - copy_parameters: Include a field to specify whether to copy parameters from the original instance (default True). - copy_lines: Include a field to specify whether to copy line items from the original instance (default False). - copy_extra_lines: Include a field to specify whether to copy extra line items from the original instance (default False). copy_fields: Optional list of dicts, each describing one boolean copy toggle. Keys: name: (str, required) @@ -1002,6 +999,15 @@ class DuplicateOptionsSerializer(serializers.Serializer): super().__init__(*args, **kwargs) + # Re-class the instance with a model-specific subclass, + # so that each model generates a unique schema component name + if self.__class__ is DuplicateOptionsSerializer: + self.__class__ = type( + f'{queryset.model.__name__}DuplicateOptionsSerializer', + (DuplicateOptionsSerializer,), + {}, + ) + self.fields['original'] = serializers.PrimaryKeyRelatedField( queryset=queryset, required=True,