diff --git a/InvenTree/part/migrations/0014_partparameter.py b/InvenTree/part/migrations/0014_partparameter.py new file mode 100644 index 0000000000..a1eef38ec6 --- /dev/null +++ b/InvenTree/part/migrations/0014_partparameter.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.4 on 2019-08-20 02:30 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0013_auto_20190628_0951'), + ] + + operations = [ + migrations.CreateModel( + name='PartParameter', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(help_text='Parameter Name', max_length=100)), + ('data', models.CharField(help_text='Parameter Value', max_length=100)), + ('part', models.ForeignKey(help_text='Parent Part', on_delete=django.db.models.deletion.CASCADE, related_name='parameters', to='part.Part')), + ], + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 2e9e748e99..95a36f4804 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -1028,6 +1028,28 @@ class PartStar(models.Model): unique_together = ['part', 'user'] +class PartParameter(models.Model): + """ A PartParameter provides key:value pairs for extra + parameters fields/values to be added to a Part. + This allows users to arbitrarily assign data fields to a Part + beyond the built-in attributes. + + Attributes: + part: Link to a Part object + name: The name (key) of the Parameter [string] + data: The data (value) of the Parameter [string] + """ + + part = models.ForeignKey(Part, on_delete=models.CASCADE, + related_name='parameters', + help_text='Parent Part', + ) + + name = models.CharField(max_length=100, help_text='Parameter Name') + + data = models.CharField(max_length=100, help_text='Parameter Value') + + class BomItem(models.Model): """ A BomItem links a part to its component items. A part can have a BOM (bill of materials) which defines