Skip to content

Commit

Permalink
#12255 fix init
Browse files Browse the repository at this point in the history
  • Loading branch information
arthanson committed Apr 19, 2023
1 parent 700ee12 commit 268f894
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions netbox/dcim/models/device_component_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def instantiate(self, device):
"""
raise NotImplementedError()

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# Cache the original DeviceType ID for reference under clean()
self._original_device_type = self.device_type_id

def to_objectchange(self, action):
objectchange = super().to_objectchange(action)
objectchange.related_object = self.device_type
Expand All @@ -90,7 +96,7 @@ def to_objectchange(self, action):
def clean(self):
super().clean()

if (not self._can_switch_device) and (self.pk is not None) and (self._original_device != self.device_id):
if (not self._can_switch_device) and (self.pk is not None) and (self._original_device_type != self.device_type_id):
raise ValidationError({
"device_type": "Component templates cannot be moved to a different device type."
})
Expand Down Expand Up @@ -129,12 +135,6 @@ class Meta:
),
)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# Cache the original DeviceType ID for reference under clean()
self._original_device_type = self.device_type_id

def to_objectchange(self, action):
objectchange = super().to_objectchange(action)
if self.device_type is not None:
Expand Down

0 comments on commit 268f894

Please sign in to comment.