Просмотр исходного кода

Fixes #7321: Don't overwrite multi-select custom fields during bulk edit

jeremystretch 4 лет назад
Родитель
Сommit
0db4092266
2 измененных файлов с 3 добавлено и 2 удалено
  1. 1 0
      docs/release-notes/version-3.0.md
  2. 2 2
      netbox/netbox/views/generic.py

+ 1 - 0
docs/release-notes/version-3.0.md

@@ -4,6 +4,7 @@
 
 ### Bug Fixes
 
+* [#7321](https://github.com/netbox-community/netbox/issues/7321) - Don't overwrite multi-select custom fields during bulk edit
 * [#7324](https://github.com/netbox-community/netbox/issues/7324) - Fix TypeError exception in web UI when filtering objects using single-choice filters
 
 ## v3.0.3 (2021-09-20)

+ 2 - 2
netbox/netbox/views/generic.py

@@ -824,14 +824,14 @@ class BulkEditView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View):
                                     if form.cleaned_data[name]:
                                         getattr(obj, name).set(form.cleaned_data[name])
                                 # Normal fields
-                                elif form.cleaned_data[name] not in (None, '', []):
+                                elif name in form.changed_data:
                                     setattr(obj, name, form.cleaned_data[name])
 
                             # Update custom fields
                             for name in custom_fields:
                                 if name in form.nullable_fields and name in nullified_fields:
                                     obj.custom_field_data[name] = None
-                                elif form.cleaned_data.get(name) not in (None, ''):
+                                elif name in form.changed_data:
                                     obj.custom_field_data[name] = form.cleaned_data[name]
 
                             obj.full_clean()