From 62922968766ff611a2e36229c701157c522d297b Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:08:50 -0700 Subject: [PATCH] Fix: trigger move and rename after custom fields saved (#7927) --- src/documents/signals/handlers.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py index f18cf1c9b..93d201e91 100644 --- a/src/documents/signals/handlers.py +++ b/src/documents/signals/handlers.py @@ -364,9 +364,17 @@ class CannotMoveFilesException(Exception): pass +@receiver(models.signals.post_save, sender=CustomFieldInstance) @receiver(models.signals.m2m_changed, sender=Document.tags.through) @receiver(models.signals.post_save, sender=Document) -def update_filename_and_move_files(sender, instance: Document, **kwargs): +def update_filename_and_move_files( + sender, + instance: Document | CustomFieldInstance, + **kwargs, +): + if isinstance(instance, CustomFieldInstance): + instance = instance.document + def validate_move(instance, old_path, new_path): if not os.path.isfile(old_path): # Can't do anything if the old file does not exist anymore.