From 84d0d0bd785779af3e6b7957c74448111ee8e2dc Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Mon, 30 Sep 2024 15:06:03 -0700 Subject: [PATCH] 16783 review changes --- netbox/dcim/api/serializers_/device_components.py | 4 ++-- netbox/dcim/forms/bulk_import.py | 4 ++-- netbox/dcim/forms/model_forms.py | 4 ++-- netbox/dcim/models/device_components.py | 14 +++++++------- netbox/dcim/tables/devices.py | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/netbox/dcim/api/serializers_/device_components.py b/netbox/dcim/api/serializers_/device_components.py index 790eb313c..db029be7b 100644 --- a/netbox/dcim/api/serializers_/device_components.py +++ b/netbox/dcim/api/serializers_/device_components.py @@ -350,8 +350,8 @@ class InventoryItemSerializer(NetBoxModelSerializer): class Meta: model = InventoryItem fields = [ - 'id', 'url', 'display_url', 'display', 'device', 'parent', 'name', 'label', 'role', 'manufacturer', - 'part_id', 'serial', 'asset_tag', 'discovered', 'description', 'component_type', 'component_id', 'status', + 'id', 'url', 'display_url', 'display', 'device', 'parent', 'name', 'label', 'status', 'role', 'manufacturer', + 'part_id', 'serial', 'asset_tag', 'discovered', 'description', 'component_type', 'component_id', 'component', 'tags', 'custom_fields', 'created', 'last_updated', '_depth', ] brief_fields = ('id', 'url', 'display', 'device', 'name', 'description', '_depth') diff --git a/netbox/dcim/forms/bulk_import.py b/netbox/dcim/forms/bulk_import.py index cbbccb2fd..f1639099e 100644 --- a/netbox/dcim/forms/bulk_import.py +++ b/netbox/dcim/forms/bulk_import.py @@ -1112,8 +1112,8 @@ class InventoryItemImportForm(NetBoxModelImportForm): class Meta: model = InventoryItem fields = ( - 'device', 'name', 'label', 'role', 'manufacturer', 'parent', 'part_id', 'serial', 'asset_tag', 'discovered', - 'status', 'description', 'tags', 'component_type', 'component_name', + 'device', 'name', 'label', 'status', 'role', 'manufacturer', 'parent', 'part_id', 'serial', 'asset_tag', 'discovered', + 'description', 'tags', 'component_type', 'component_name', ) def __init__(self, *args, **kwargs): diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index afb7d358e..df4520ad3 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -1576,8 +1576,8 @@ class InventoryItemForm(DeviceComponentForm): ) fieldsets = ( - FieldSet('device', 'parent', 'name', 'label', 'role', 'description', 'tags', name=_('Inventory Item')), - FieldSet('manufacturer', 'part_id', 'serial', 'asset_tag', 'status', name=_('Hardware')), + FieldSet('device', 'parent', 'name', 'label', 'status', 'role', 'description', 'tags', name=_('Inventory Item')), + FieldSet('manufacturer', 'part_id', 'serial', 'asset_tag', name=_('Hardware')), FieldSet( TabbedGroups( FieldSet('interface', name=_('Interface')), diff --git a/netbox/dcim/models/device_components.py b/netbox/dcim/models/device_components.py index 0b937a6a0..9f18032e5 100644 --- a/netbox/dcim/models/device_components.py +++ b/netbox/dcim/models/device_components.py @@ -1244,6 +1244,12 @@ class InventoryItem(MPTTModel, ComponentModel, TrackingModelMixin): ct_field='component_type', fk_field='component_id' ) + status = models.CharField( + verbose_name=_('status'), + max_length=50, + choices=InventoryItemStatusChoices, + default=InventoryItemStatusChoices.STATUS_ACTIVE + ) role = models.ForeignKey( to='dcim.InventoryItemRole', on_delete=models.PROTECT, @@ -1282,16 +1288,10 @@ class InventoryItem(MPTTModel, ComponentModel, TrackingModelMixin): default=False, help_text=_('This item was automatically discovered') ) - status = models.CharField( - verbose_name=_('status'), - max_length=50, - choices=InventoryItemStatusChoices, - default=InventoryItemStatusChoices.STATUS_ACTIVE - ) objects = TreeManager() - clone_fields = ('device', 'parent', 'role', 'manufacturer', 'part_id', 'status') + clone_fields = ('device', 'parent', 'role', 'manufacturer', 'status', 'part_id') class Meta: ordering = ('device__id', 'parent__id', '_name') diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index 77d1ad7de..efa5efddb 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -961,11 +961,11 @@ class InventoryItemTable(DeviceComponentTable): class Meta(NetBoxTable.Meta): model = models.InventoryItem fields = ( - 'pk', 'id', 'name', 'device', 'parent', 'component', 'label', 'role', 'manufacturer', 'part_id', 'serial', - 'asset_tag', 'status', 'description', 'discovered', 'tags', 'created', 'last_updated', + 'pk', 'id', 'name', 'device', 'parent', 'component', 'label', 'status', 'role', 'manufacturer', 'part_id', 'serial', + 'asset_tag', 'description', 'discovered', 'tags', 'created', 'last_updated', ) default_columns = ( - 'pk', 'name', 'device', 'label', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'status', + 'pk', 'name', 'device', 'label', 'status', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', ) @@ -981,11 +981,11 @@ class DeviceInventoryItemTable(InventoryItemTable): class Meta(NetBoxTable.Meta): model = models.InventoryItem fields = ( - 'pk', 'id', 'name', 'label', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'component', + 'pk', 'id', 'name', 'label', 'status', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'component', 'description', 'discovered', 'tags', 'actions', ) default_columns = ( - 'pk', 'name', 'label', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'component', + 'pk', 'name', 'label', 'status', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'component', )