mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-08 04:56:56 -06:00
Fixes #20114: Preserve parent bay during device bulk import when tags are present (#21019)
Some checks failed
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Lock threads / lock (push) Has been cancelled
Close stale issues/PRs / stale (push) Has been cancelled
Close incomplete issues / stale (push) Has been cancelled
Update translation strings / makemessages (push) Has been cancelled
CI / build (20.x, 3.10) (push) Has been cancelled
CI / build (20.x, 3.11) (push) Has been cancelled
CI / build (20.x, 3.12) (push) Has been cancelled
Some checks failed
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Lock threads / lock (push) Has been cancelled
Close stale issues/PRs / stale (push) Has been cancelled
Close incomplete issues / stale (push) Has been cancelled
Update translation strings / makemessages (push) Has been cancelled
CI / build (20.x, 3.10) (push) Has been cancelled
CI / build (20.x, 3.11) (push) Has been cancelled
CI / build (20.x, 3.12) (push) Has been cancelled
This commit is contained in:
@@ -2454,11 +2454,12 @@ class DeviceBulkImportView(generic.BulkImportView):
|
|||||||
model_form = forms.DeviceImportForm
|
model_form = forms.DeviceImportForm
|
||||||
|
|
||||||
def save_object(self, object_form, request):
|
def save_object(self, object_form, request):
|
||||||
|
parent_bay = getattr(object_form.instance, 'parent_bay', None)
|
||||||
obj = object_form.save()
|
obj = object_form.save()
|
||||||
|
|
||||||
# For child devices, save the reverse relation to the parent device bay
|
# For child devices, save the reverse relation to the parent device bay
|
||||||
if getattr(obj, 'parent_bay', None):
|
if parent_bay:
|
||||||
device_bay = obj.parent_bay
|
device_bay = parent_bay
|
||||||
device_bay.installed_device = obj
|
device_bay.installed_device = obj
|
||||||
device_bay.save()
|
device_bay.save()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user