-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scripts are not increasing counter for device components like power ports and inventory items #14446
Comments
Please share the script that someone else can run locally to reproduce the reported behavior. |
Sure, Jeremy
|
I'm not able to reproduce the reported behavior on NetBox v3.6.7. It has likely been addressed in the latest release by #14081. Please try upgrading, and ask that this issue be re-opened if you find that the bug persists. |
The bug persists. I just upgraded to v3.6.8 and inventory items count still wrong. I'm also updating via scripts.
Even if I remove all the inventory items before creation, counter remains wrong.
|
@rizlas - The issue is, at least in @cichutkiii example, that the device is saved after the inventoryitem is added. So a script like this (simplified from the earlier example) will make the count bug:
Instead the end would have to be:
I guess another option would be to use the This is not a bug in netbox, however it is bad practice and not intuitive to modify fields on other objects in a non-obvious way like it was done when the cached item counts were added. I wouldn't count on it changing, so you have to update your scripts. |
I wasn't aware of refresh_from_db. Fine to me, make sense. But, I just tested your suggestion and the counter it still wrong. This was my approach before testing your solution:
After your suggestion:
Nothing changed |
NetBox version
v3.6.4
Python version
3.8
Steps to Reproduce
Expected Behavior
counter should count newly added items by script
Observed Behavior
counter is not working while running script
And while removing items I'm getting to the situation when I have counter below 0
The text was updated successfully, but these errors were encountered: