prevent duplicate save event when creating a part (#12406)

This commit is contained in:
Oliver 2026-07-16 14:23:44 +10:00 committed by GitHub
parent 3fd0e9d304
commit a09479665a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 4 deletions

View File

@ -1038,12 +1038,13 @@ class PartSerializer(
initial_supplier = validated_data.pop('initial_supplier', None)
copy_category_parameters = validated_data.pop('copy_category_parameters', False)
instance = super().create(validated_data)
# Additional data to apply to the serializer
extra_data = {}
# Save user information
if request := self.context.get('request'):
instance.creation_user = request.user
instance.save()
extra_data['creation_user'] = request.user
instance = super().create({**validated_data, **extra_data})
# Copy data from original Part
if duplicate: