Skip to content

Commit

Permalink
Closes #1692: Allow assigment of inventory items to parent items in w…
Browse files Browse the repository at this point in the history
…eb UI
  • Loading branch information
jeremystretch committed Sep 18, 2020
1 parent 230e7bb commit 52dc802
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/version-2.10.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### New Features

* [#1692](https://github.com/netbox-community/netbox/issues/1692) - Allow assigment of inventory items to parent items in web UI
* [#5146](https://github.com/netbox-community/netbox/issues/5146) - Add custom fields support for cables, power panels, rack reservations, and virtual chassis

### Other Changes
Expand Down
21 changes: 18 additions & 3 deletions netbox/dcim/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3284,6 +3284,13 @@ class InventoryItemForm(BootstrapMixin, forms.ModelForm):
queryset=Device.objects.all(),
display_field='display_name'
)
parent = DynamicModelChoiceField(
queryset=InventoryItem.objects.all(),
required=False,
query_params={
'device_id': '$device'
}
)
manufacturer = DynamicModelChoiceField(
queryset=Manufacturer.objects.all(),
required=False
Expand All @@ -3296,7 +3303,8 @@ class InventoryItemForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = InventoryItem
fields = [
'name', 'label', 'device', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description', 'tags',
'device', 'parent', 'name', 'label', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description',
'tags',
]


Expand All @@ -3305,6 +3313,13 @@ class InventoryItemCreateForm(ComponentCreateForm):
queryset=Manufacturer.objects.all(),
required=False
)
parent = DynamicModelChoiceField(
queryset=InventoryItem.objects.all(),
required=False,
query_params={
'device_id': '$device'
}
)
part_id = forms.CharField(
max_length=50,
required=False,
Expand All @@ -3319,8 +3334,8 @@ class InventoryItemCreateForm(ComponentCreateForm):
required=False,
)
field_order = (
'device', 'name_pattern', 'label_pattern', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description',
'tags',
'device', 'parent', 'name_pattern', 'label_pattern', 'manufacturer', 'part_id', 'serial', 'asset_tag',
'description', 'tags',
)


Expand Down
2 changes: 1 addition & 1 deletion netbox/templates/dcim/inc/inventoryitem.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<td>{{ item.description|placeholder }}</td>
<td class="text-right noprint">
{% if perms.dcim.change_inventoryitem %}
<a href="{% url 'dcim:inventoryitem_edit' pk=item.pk %}" class="btn btn-xs btn-warning"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
<a href="{% url 'dcim:inventoryitem_edit' pk=item.pk %}?return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-xs btn-warning"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
{% endif %}
{% if perms.dcim.delete_inventoryitem %}
<a href="{% url 'dcim:inventoryitem_delete' pk=item.pk %}?return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
Expand Down

0 comments on commit 52dc802

Please sign in to comment.