mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-17 04:32:51 -06:00
Fixes #12074: Move automatic location assignment out of clean()
* 12074 fix full clean * 12074 move device location setting to save from clean * 12074 fix set location only if present in rack * Update base.py --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
parent
3264636b7a
commit
2883fa14de
@ -659,8 +659,6 @@ class Device(PrimaryModel, ConfigContextModel):
|
||||
raise ValidationError({
|
||||
'rack': f"Rack {self.rack} does not belong to location {self.location}.",
|
||||
})
|
||||
elif self.rack:
|
||||
self.location = self.rack.location
|
||||
|
||||
if self.rack is None:
|
||||
if self.face:
|
||||
@ -801,6 +799,9 @@ class Device(PrimaryModel, ConfigContextModel):
|
||||
if is_new and not self.airflow:
|
||||
self.airflow = self.device_type.airflow
|
||||
|
||||
if self.rack and self.rack.location:
|
||||
self.location = self.rack.location
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
# If this is a new Device, instantiate all the related components per the DeviceType definition
|
||||
|
Loading…
Reference in New Issue
Block a user