Do the clear in one operation

This commit is contained in:
shamoon
2025-11-27 10:06:08 -08:00
parent 15cf23fd6a
commit 31e6806d76

View File

@@ -547,12 +547,12 @@ def process_cf_select_update(custom_field: CustomField):
for option in custom_field.extra_data.get("select_options", []) for option in custom_field.extra_data.get("select_options", [])
} }
for cf_instance in custom_field.fields.select_related("document").iterator(): # Clear select values that no longer exist
# Check if the current value is still a valid option custom_field.fields.exclude(
if cf_instance.value not in select_options: value_select__in=select_options.keys(),
cf_instance.value_select = None ).update(value_select=None)
cf_instance.save(update_fields=["value_select"])
for cf_instance in custom_field.fields.select_related("document").iterator():
# Update the filename and move files if necessary # Update the filename and move files if necessary
update_filename_and_move_files(CustomFieldInstance, cf_instance) update_filename_and_move_files(CustomFieldInstance, cf_instance)