Browse Source

Don't adopt components already belonging to a module

kkthxbye-code 3 years ago
parent
commit
81c7fe2084
1 changed files with 2 additions and 1 deletions
  1. 2 1
      netbox/dcim/models/devices.py

+ 2 - 1
netbox/dcim/models/devices.py

@@ -1091,7 +1091,8 @@ class Module(NetBoxModel, ConfigContextModel):
                 template_instance = template.instantiate(device=self.device, module=self)
 
                 if adopt_components:
-                    existing_item = getattr(self.device, component_attribute).filter(name=template_instance.name).first()
+                    existing_item = getattr(self.device, component_attribute).filter(
+                        module__isnull=True, name=template_instance.name).first()
 
                     # Check if there's a component with the same name already
                     if existing_item: