ArnesSI / netbox-inventory

Manage your hardware inventory in NetBox
MIT License
205 stars 21 forks source link

Asset tag is not unique #149

Closed alehaa closed 2 months ago

alehaa commented 7 months ago

When you add a bunch of items using Create & Add Another, the value of the Asset Tag is copied to the next form. However, this is confusing because an asset tag should be unique somehow to uniquely identify an asset.

After looking at the NetBox code, I see that the dcim.Device model uses a unique constraint for field asset_tag, so I'd suggest doing the same for this plugin to have consistent behavior.

matejv commented 5 months ago

netbox_inventory enforces that the combination of asset.owner and asset.asset_tag is unique.

I intentionally keep the old asset tag value when using "Create & add another" since my thinking is: if you're adding multiple of similar asset in a row, and you keep track of asset tags, it's likely that your asset tags will be sequential. Sou you can just increment the last number of old asset tag instead of having to type the whole value in again (increasing the chance of a type in the process).

What I did miss is that if the asset owner is not set, the asset tag value uniqueness is then not enforced. I'll take a look how this can be done.