diff --git a/InvenTree/part/migrations/0031_auto_20200318_1044.py b/InvenTree/part/migrations/0031_auto_20200318_1044.py new file mode 100644 index 0000000000..c43af364f2 --- /dev/null +++ b/InvenTree/part/migrations/0031_auto_20200318_1044.py @@ -0,0 +1,31 @@ +# Generated by Django 2.2.9 on 2020-03-18 10:44 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('part', '0030_auto_20200318_1027'), + ] + + operations = [ + migrations.AddField( + model_name='part', + name='creation_date', + field=models.DateField(auto_now_add=True, null=True), + ), + migrations.AddField( + model_name='part', + name='creation_user', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='parts_created', to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='part', + name='responsible', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='parts_responible', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 312cdcaa69..39c61079ea 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -226,6 +226,9 @@ class Part(models.Model): active: Is this part active? Parts are deactivated instead of being deleted virtual: Is this part "virtual"? e.g. a software product or similar notes: Additional notes field for this part + creation_date: Date that this part was added to the database + creation_user: User who added this part to the database + responsible: User who is responsible for this part (optional) """ class Meta: @@ -448,6 +451,12 @@ class Part(models.Model): bom_checked_date = models.DateField(blank=True, null=True) + creation_date = models.DateField(auto_now_add=True, editable=False, blank=True, null=True) + + creation_user = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True, related_name='parts_created') + + responsible = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True, related_name='parts_responible') + def format_barcode(self): """ Return a JSON string for formatting a barcode for this Part object """