-
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
Calling save() on InventoryItem without changes produces unnecessary changelog entry #6599
Comments
For now I have worked around this in my scripts by doing this: - iitem.part_id = psu['name']
- iitem.serial = psu['serialNum']
- iitem.discovered = True
- iitem.save()
+ if iitem.part_id != psu['name'] or iitem.serial != psu['serialNum'] or not iitem.discovered:
+ iitem.snapshot()
+ iitem.part_id = psu['name']
+ iitem.serial = psu['serialNum']
+ iitem.discovered = True
+ iitem.save() If this is the intended way going forward I am OK with updating my scripts accordingly but ask that e.g. the example Custom Script is updated with this information on how to best do changes. |
This intended behavior. Even when no data is being modified, there may still be a desire to record that a save event took place. |
Ok thanks for confirming. I would suggest adding a section to https://netbox.readthedocs.io/en/stable/additional-features/custom-scripts/ describing the semantics around save() and snapshot(). It was quite hard going down the rabbit hole of Django data models and how things are supposed to work together, so that might be useful for people. |
NetBox version
v2.11.6
Python version
3.7
Steps to Reproduce
save()
on an InventoryItem via Netbox Script:If I call
.snapshot()
before the "Pre-Change Data" is populated, and the UI shows "No difference".Expected Behavior
.snapshot()
is important for Netbox Scripts on the https://netbox.readthedocs.io/en/stable/additional-features/custom-scripts/ website, or make it automatic, would be appreciated.save()
with no changes is silent/ignored.Observed Behavior
An moot changelog entry is created.
The text was updated successfully, but these errors were encountered: