A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Chore: more efficient select cf update handler (#9099)
shamoon17bb3ebbf543
diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.pyindex 5da9ef879..0079e5f8c 100644--- a/src/documents/signals/handlers.py+++ b/src/documents/signals/handlers.py@@ -525,19 +525,21 @@ def check_paths_and_prune_custom_fields(sender, instance: CustomField, **kwargs)"""if (instance.data_type == CustomField.FieldDataType.SELECT+ and instance.fields.count() > 0+ and instance.extra_data): # Only select fields, for now+ select_options = {+ option["id"]: option["label"]+ for option in instance.extra_data.get("select_options", [])+ }+for cf_instance in instance.fields.all():- options = instance.extra_data.get("select_options", [])- try:- next(- option["label"]- for option in options- if option["id"] == cf_instance.value- )- except StopIteration:- # The value of this custom field instance is not in the select options anymore+ # Check if the current value is still a valid option+ if cf_instance.value not in select_options:cf_instance.value_select = None- cf_instance.save()+ cf_instance.save(update_fields=["value_select"])++ # Update the filename and move files if necessaryupdate_filename_and_move_files(sender, cf_instance)