diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py index 1561b8dc9..7d4891308 100644 --- a/netbox/dcim/api/serializers.py +++ b/netbox/dcim/api/serializers.py @@ -669,14 +669,20 @@ class InventoryItemSerializer(serializers.ModelSerializer): class Meta: model = InventoryItem - fields = ['id', 'device', 'parent', 'name', 'manufacturer', 'part_id', 'serial', 'discovered'] + fields = [ + 'id', 'device', 'parent', 'name', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'discovered', + 'description', + ] class WritableInventoryItemSerializer(serializers.ModelSerializer): class Meta: model = InventoryItem - fields = ['id', 'device', 'parent', 'name', 'manufacturer', 'part_id', 'serial', 'discovered'] + fields = [ + 'id', 'device', 'parent', 'name', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'discovered', + 'description', + ] # diff --git a/netbox/dcim/filters.py b/netbox/dcim/filters.py index e9d629045..2669e7d8c 100644 --- a/netbox/dcim/filters.py +++ b/netbox/dcim/filters.py @@ -599,7 +599,7 @@ class InventoryItemFilter(DeviceComponentFilterSet): class Meta: model = InventoryItem - fields = ['name', 'part_id', 'serial', 'discovered'] + fields = ['name', 'part_id', 'serial', 'asset_tag', 'discovered'] class ConsoleConnectionFilter(django_filters.FilterSet): diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index b23e4a23e..337cea86e 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -1765,4 +1765,4 @@ class InventoryItemForm(BootstrapMixin, forms.ModelForm): class Meta: model = InventoryItem - fields = ['name', 'manufacturer', 'part_id', 'serial'] + fields = ['name', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description'] diff --git a/netbox/dcim/migrations/0040_inventoryitem_add_asset_tag_description.py b/netbox/dcim/migrations/0040_inventoryitem_add_asset_tag_description.py new file mode 100644 index 000000000..c7d49fe2c --- /dev/null +++ b/netbox/dcim/migrations/0040_inventoryitem_add_asset_tag_description.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2017-06-23 20:44 +from __future__ import unicode_literals + +from django.db import migrations, models +import utilities.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('dcim', '0039_interface_add_enabled_mtu'), + ] + + operations = [ + migrations.AddField( + model_name='inventoryitem', + name='asset_tag', + field=utilities.fields.NullableCharField(blank=True, help_text='A unique tag used to identify this item', max_length=50, null=True, unique=True, verbose_name='Asset tag'), + ), + migrations.AddField( + model_name='inventoryitem', + name='description', + field=models.CharField(blank=True, max_length=100), + ), + ] diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index 4f76de1e6..d8a69e4d3 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -1306,11 +1306,18 @@ class InventoryItem(models.Model): device = models.ForeignKey('Device', related_name='inventory_items', on_delete=models.CASCADE) parent = models.ForeignKey('self', related_name='child_items', blank=True, null=True, on_delete=models.CASCADE) name = models.CharField(max_length=50, verbose_name='Name') - manufacturer = models.ForeignKey('Manufacturer', related_name='inventory_items', blank=True, null=True, - on_delete=models.PROTECT) + manufacturer = models.ForeignKey( + 'Manufacturer', models.PROTECT, related_name='inventory_items', blank=True, null=True + ) part_id = models.CharField(max_length=50, verbose_name='Part ID', blank=True) serial = models.CharField(max_length=50, verbose_name='Serial number', blank=True) + asset_tag = NullableCharField( + max_length=50, blank=True, null=True, unique=True, verbose_name='Asset tag', + help_text='A unique tag used to identify this item' + ) discovered = models.BooleanField(default=False, verbose_name='Discovered') + description = models.CharField(max_length=100, blank=True) + class Meta: ordering = ['device__id', 'parent__id', 'name'] diff --git a/netbox/templates/dcim/device_inventory.html b/netbox/templates/dcim/device_inventory.html index cc3dd361b..32b15670c 100644 --- a/netbox/templates/dcim/device_inventory.html +++ b/netbox/templates/dcim/device_inventory.html @@ -51,6 +51,8 @@ Manufacturer Part Number Serial Number + Asset Tag + Description diff --git a/netbox/templates/dcim/inc/inventoryitem.html b/netbox/templates/dcim/inc/inventoryitem.html index 6aa77d1c2..8bc3149b1 100644 --- a/netbox/templates/dcim/inc/inventoryitem.html +++ b/netbox/templates/dcim/inc/inventoryitem.html @@ -1,9 +1,11 @@ {{ item.name }} {% if not item.discovered %}{% endif %} - {{ item.manufacturer|default:'' }} + {{ item.manufacturer|default:"" }} {{ item.part_id }} {{ item.serial }} + {{ item.asset_tag|default:"" }} + {{ item.description }} {% if perms.dcim.change_inventoryitem %}