Add 'add' action for inventory items panel

This commit is contained in:
Jeremy Stretch
2026-03-19 10:24:14 -04:00
parent 18779a222e
commit 3bdbbc4116
+11 -1
View File
@@ -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)