netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Inventory Item editing problem

Open nmisaki opened this issue 2 years ago • 1 comments

NetBox version

v3.2.7

Python version

3.10

Steps to Reproduce

  1. Click "Edit" button on any inventory item which associated with Device A / Interface A
  2. Change device field to Device B
  3. Click "Save" button

Expected Behavior

"Component" link should be changed to Device B

Observed Behavior

"Component" link was Device A / Interface A

nmisaki avatar Aug 02 '22 10:08 nmisaki

"Component" link should be changed to Device B

Should it? I agree that there is a bug here as moving an interface item with a link to a component leaves it in an inconsistant state, but how would moving it work? We can't just move the component to the other device. We also can't just find a component with the same name reliably.

One of the following might be a solution:

  1. Reject when saving with an error indicating that it's not possible to move inventory items that have a link to a component.
  2. Remove the link when moving an inventory item.

The inventory item -> component link is a little weird to begin with though, as there is no way to "unlink" them without deleting the inventory item afaik. Not sure what the correct solution is here.

kkthxbye-code avatar Aug 02 '22 11:08 kkthxbye-code

The "device" field is simply a filter field, it is not an accurate reflection of the current device. If you change the device and then select the component dropdown it should populate it with components from the new device that you can select, but you must select one of those new componets.

DanSheps avatar Aug 31 '22 22:08 DanSheps

@DanSheps - I'm not sure I follow Dan. Are you saying it should be like that or that it is? Because Device is definitely not just a filter field in this case, it decides the device field of the InventoryItem model. It is also possible to update the device of the InventoryItem through the API, are you saying that this is unintended as well?

it is not an accurate reflection of the current device

I mean it is here, which is what causes the bug as it is neither synchronized with the parent component or validated against it.

kkthxbye-code avatar Sep 01 '22 05:09 kkthxbye-code

You are right, going to blame that on me being a rush to get to dinner. Forgot that it was also a component model.

Anyways, we don't allow changing front port/rear port/interface, that could be part of the bug. However Inventory is a lititle different in that often it is a removeable so perhaps we should allow changes; however there is no way to re-associate it to another component from what I can tell, in the GUI. It is also likely that it is intended to not be moveable based on the behaviour we are seeing.

Based on this I would say, for now we should raise a error that it is not moveable.

DanSheps avatar Sep 01 '22 13:09 DanSheps

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

github-actions[bot] avatar Nov 01 '22 04:11 github-actions[bot]

As of NetBox v3.3.8 it's not possible to change the device to which an inventory item is assigned, so this can no longer be reproduced. Please see #10447 for further discussion relating to this functionality.

jeremystretch avatar Nov 17 '22 20:11 jeremystretch