diff --git a/InvenTree/stock/migrations/0045_stockitem_customer.py b/InvenTree/stock/migrations/0045_stockitem_customer.py new file mode 100644 index 0000000000..497d6b7353 --- /dev/null +++ b/InvenTree/stock/migrations/0045_stockitem_customer.py @@ -0,0 +1,20 @@ +# Generated by Django 3.0.5 on 2020-06-04 03:20 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('company', '0021_remove_supplierpart_manufacturer_name'), + ('stock', '0044_auto_20200528_1036'), + ] + + operations = [ + migrations.AddField( + model_name='stockitem', + name='customer', + field=models.ForeignKey(help_text='Customer', limit_choices_to={'is_customer': True}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assigned_stock', to='company.Company', verbose_name='Customer'), + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 7bebdefaba..4e18842304 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -32,6 +32,7 @@ from InvenTree.status_codes import StockStatus from InvenTree.models import InvenTreeTree, InvenTreeAttachment from InvenTree.fields import InvenTreeURLField +from company import models as CompanyModels from part import models as PartModels @@ -352,6 +353,16 @@ class StockItem(MPTTModel): help_text=_('Is this item installed in another item?') ) + customer = models.ForeignKey( + CompanyModels.Company, + on_delete=models.SET_NULL, + null=True, + limit_choices_to={'is_customer': True}, + related_name='assigned_stock', + help_text=_("Customer"), + verbose_name=_("Customer"), + ) + serial = models.PositiveIntegerField( verbose_name=_('Serial Number'), blank=True, null=True,