mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
#12255 allow inventory items to change devices
This commit is contained in:
parent
c1c98f9883
commit
f3413e1851
@ -67,6 +67,7 @@ class ComponentModel(NetBoxModel):
|
|||||||
max_length=200,
|
max_length=200,
|
||||||
blank=True
|
blank=True
|
||||||
)
|
)
|
||||||
|
_can_switch_device = False
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
@ -97,7 +98,7 @@ class ComponentModel(NetBoxModel):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
if 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 != self.device_id):
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
"device": "Components cannot be moved to a different device."
|
"device": "Components cannot be moved to a different device."
|
||||||
})
|
})
|
||||||
@ -1128,6 +1129,7 @@ class InventoryItem(MPTTModel, ComponentModel):
|
|||||||
objects = TreeManager()
|
objects = TreeManager()
|
||||||
|
|
||||||
clone_fields = ('device', 'parent', 'role', 'manufacturer', 'part_id',)
|
clone_fields = ('device', 'parent', 'role', 'manufacturer', 'part_id',)
|
||||||
|
_can_switch_device = True
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('device__id', 'parent__id', '_name')
|
ordering = ('device__id', 'parent__id', '_name')
|
||||||
|
Loading…
Reference in New Issue
Block a user