ArnesSI / netbox-inventory

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

Add device and module type columns #161

Closed alehaa closed 4 months ago

alehaa commented 7 months ago

A linked count column added to the device and module type list tables allows for quick access to the associated assets, while providing an overview of the total assets managed as opposed to instances in use. This also allows both columns to be exported as CSV.

matejv commented 6 months ago

Does this code work for you? I get zeros for all device types even those that have assets.

I think the issue is that we don't setup a reverse relation from Asset to DeviceType (...), see here.

I know this was done intentionally, however I can't remember why. It's possible I encountered some issues but it's also possible I didn't want to risk any namespace collisions. Eg. if netbox or other plugins tried to setup reverse relation with the same name. Django complains and fails in such case.

alehaa commented 6 months ago

Hmm. Indeed, I had a reverse relationship requested for testing, but not committed. However, adding this could introduce new problems in the future as I'm working on a feature in NetBox to automatically display related objects. Assets of DeviceType and ModuleType objects would then be displayed twice in the related detail views.

I'll see if I can change the columns to use a dedicated lookup instead of relations.

alehaa commented 6 months ago

I've added the reverse relation, which allows the columns to work now.

However, adding this could introduce new problems in the future as I'm working on a feature in NetBox to automatically display related objects.

This doesn't seem to be a problem. The detailed view of Assets with different kind is on the manufacturer's view. However, these relations would be shown on the views for DeviceType and ModuleType.