From 3bdbbc4116c4f5b8a46288760c4eb5bcdf6ce68e Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 19 Mar 2026 10:24:14 -0400 Subject: [PATCH] Add 'add' action for inventory items panel --- netbox/dcim/ui/panels.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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)