1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #11156 - Allow InventoryItem component reassignment (#11256)

* Allow re-assigning InventoryItem components

* Refactor logic for finding initial component assignment on InventoryItems

* PEP8 fix

* Fix wrong HTML causing tab list to extend past the end of the parent row

* Tweak form field labels

Co-authored-by: jeremystretch <jstretch@ns1.com>
This commit is contained in:
kkthxbye
2023-01-03 16:13:34 +01:00
committed by GitHub
parent 1c636ea127
commit b9f8370097
4 changed files with 212 additions and 23 deletions

View File

@@ -1146,3 +1146,8 @@ class InventoryItem(MPTTModel, ComponentModel):
# When moving an InventoryItem to another device, remove any associated component
if self.component and self.component.device != self.device:
self.component = None
else:
if self.component and self.component.device != self.device:
raise ValidationError({
"device": "Cannot assign inventory item to component on another device"
})