From c75795ceda9a09d797db94af31503bfe03d2aa66 Mon Sep 17 00:00:00 2001 From: Saria Hajjar Date: Wed, 1 Jan 2020 23:28:20 +0000 Subject: [PATCH] Ability to move inventory items between devices --- docs/release-notes/version-2.6.md | 1 + netbox/dcim/forms.py | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/version-2.6.md b/docs/release-notes/version-2.6.md index 548492438..91a795be5 100644 --- a/docs/release-notes/version-2.6.md +++ b/docs/release-notes/version-2.6.md @@ -3,6 +3,7 @@ ## Enhancements * [#3705](https://github.com/netbox-community/netbox/issues/3705) - Provide request context when executing custom scripts +* [#2288](https://github.com/netbox-community/netbox/issues/2288) - Ability to move inventory items between devices * [#3762](https://github.com/netbox-community/netbox/issues/3762) - Add date/time picker widgets * [#3788](https://github.com/netbox-community/netbox/issues/3788) - Enable partial search for inventory items diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 1774fc986..6e6cb8af8 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -3285,9 +3285,12 @@ class InventoryItemForm(BootstrapMixin, forms.ModelForm): class Meta: model = InventoryItem fields = [ - 'name', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description', 'tags', + 'name', 'device', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description', 'tags', ] widgets = { + 'device': APISelect( + api_url="/api/dcim/devices/" + ), 'manufacturer': APISelect( api_url="/api/dcim/manufacturers/" ) @@ -3323,9 +3326,19 @@ class InventoryItemBulkEditForm(BootstrapMixin, BulkEditForm): queryset=InventoryItem.objects.all(), widget=forms.MultipleHiddenInput() ) + device = forms.ModelChoiceField( + queryset=Device.objects.all(), + required=False, + widget=APISelect( + api_url="/api/dcim/devices/" + ) + ) manufacturer = forms.ModelChoiceField( queryset=Manufacturer.objects.all(), - required=False + required=False, + widget=APISelect( + api_url="/api/dcim/manufacturers/" + ) ) part_id = forms.CharField( max_length=50, @@ -3356,11 +3369,14 @@ class InventoryItemFilterForm(BootstrapMixin, forms.Form): manufacturer = FilterChoiceField( queryset=Manufacturer.objects.all(), to_field_name='slug', - null_label='-- None --' + widget=APISelect( + api_url="/api/dcim/manufacturers/", + value_field="slug", + ) ) discovered = forms.NullBooleanField( required=False, - widget=forms.Select( + widget=StaticSelect2( choices=BOOLEAN_WITH_BLANK_CHOICES ) )