mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-14 15:52:18 -06:00
Fixes #20912: Clear ModuleBay parent when module assignment removed
When a ModuleBay's module field is cleared (returning it to device-level), the parent field was not being updated, leaving stale MPTT tree data. The save() method only set parent when module was present, but failed to clear it when module was removed. Now explicitly sets parent to None when module is cleared.
This commit is contained in:
@@ -1222,6 +1222,8 @@ class ModuleBay(ModularComponentModel, TrackingModelMixin, MPTTModel):
|
||||
def save(self, *args, **kwargs):
|
||||
if self.module:
|
||||
self.parent = self.module.module_bay
|
||||
else:
|
||||
self.parent = None
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user