Fix saving doc links with no value (#5144)

This commit is contained in:
shamoon authored and GitHub committed 2023-12-28 19:57:46 +00:00
1 parent fbeb03c377
commit 76001105b8
1 file changed
+7 -1
+7 -1
View File
@@ -512,11 +512,17 @@ class CustomFieldInstanceSerializer(serializers.ModelSerializer):
field=field,
document=document,
).first()
if current_field_instance is not None:
if (
current_field_instance is not None
and current_field_instance.value is not None
):
for doc_id in current_field_instance.value:
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