Fixes #10513: Disable the reassignment of a module to a new device

This commit is contained in:
jeremystretch
2022-10-03 10:39:03 -04:00
parent de1bd6e1b6
commit 8d6c315513
4 changed files with 13 additions and 2 deletions

View File

@@ -987,6 +987,14 @@ class Module(NetBoxModel, ConfigContextModel):
def get_absolute_url(self):
return reverse('dcim:module', args=[self.pk])
def clean(self):
super().clean()
if self.module_bay.device != self.device:
raise ValidationError(
f"Module must be installed within a module bay belonging to the assigned device ({self.device})."
)
def save(self, *args, **kwargs):
is_new = self.pk is None