Fixes #6771: Add count of inventory items to manufacturer view

This commit is contained in:
jeremystretch 2021-07-28 10:25:52 -04:00
parent 0c214932ba
commit 78e282d406
3 changed files with 11 additions and 0 deletions

View File

@ -22,6 +22,7 @@
### Other Changes
* [#6771](https://github.com/netbox-community/netbox/issues/6771) - Add count of inventory items to manufacturer view
* [#6781](https://github.com/netbox-community/netbox/issues/6781) - Database query caching is now disabled by default
---

View File

@ -695,6 +695,9 @@ class ManufacturerView(generic.ObjectView):
).annotate(
instance_count=count_related(Device, 'device_type')
)
inventory_items = InventoryItem.objects.restrict(request.user, 'view').filter(
manufacturer=instance
)
devicetypes_table = tables.DeviceTypeTable(devicetypes)
devicetypes_table.columns.hide('manufacturer')
@ -702,6 +705,7 @@ class ManufacturerView(generic.ObjectView):
return {
'devicetypes_table': devicetypes_table,
'inventory_item_count': inventory_items.count(),
}

View File

@ -29,6 +29,12 @@
<a href="{% url 'dcim:devicetype_list' %}?manufacturer_id={{ object.pk }}">{{ devicetypes_table.rows|length }}</a>
</td>
</tr>
<tr>
<td>Inventory Items</td>
<td>
<a href="{% url 'dcim:inventoryitem_list' %}?manufacturer_id={{ object.pk }}">{{ inventory_item_count }}</a>
</td>
</tr>
</table>
</div>
{% plugin_left_page object %}