diff --git a/netbox/dcim/ui/panels.py b/netbox/dcim/ui/panels.py index 72b82aad0..3cd47b724 100644 --- a/netbox/dcim/ui/panels.py +++ b/netbox/dcim/ui/panels.py @@ -1,7 +1,8 @@ +from django.contrib.contenttypes.models import ContentType from django.template.loader import render_to_string from django.utils.translation import gettext_lazy as _ -from netbox.ui import attrs, panels +from netbox.ui import actions, attrs, panels class SitePanel(panels.ObjectAttributesPanel): @@ -400,6 +401,15 @@ class InventoryItemsPanel(panels.ObjectPanel): """ template_name = 'dcim/panels/component_inventory_items.html' title = _('Inventory Items') + actions = [ + actions.AddObject( + 'dcim.inventoryitem', + url_params={ + 'component_type': lambda ctx: ContentType.objects.get_for_model(ctx['object']).pk, + 'component_id': lambda ctx: ctx['object'].pk, + }, + ), + ] def render(self, context): ctx = self.get_context(context)