From 428ffb4729138d0937987314b8ef6324078b3577 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 30 Dec 2023 07:43:29 -0800 Subject: [PATCH] Fix: setting empty doc link with docs to be removed (#5174) --- src/documents/serialisers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index c07b00f78..5e8037960 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -527,6 +527,10 @@ class CustomFieldInstanceSerializer(serializers.ModelSerializer): """ Add or remove 'symmetrical' links to `document` on all `target_doc_ids` """ + + if target_doc_ids is None: + target_doc_ids = [] + # Check if any documents are going to be removed from the current list of links and remove the symmetrical links current_field_instance = CustomFieldInstance.objects.filter( field=field, @@ -540,9 +544,6 @@ class CustomFieldInstanceSerializer(serializers.ModelSerializer): if doc_id not in target_doc_ids: self.remove_doclink(document, field, doc_id) - if target_doc_ids is None: - target_doc_ids = [] - # Create an instance if target doc doesnt have this field or append it to an existing one existing_custom_field_instances = { custom_field.document_id: custom_field