Add 'customer' field to StockItem

This commit is contained in:
Oliver Walters 2020-06-04 19:08:33 +10:00
parent 4ddabb82ef
commit fbd21827fb
2 changed files with 31 additions and 0 deletions

View File

@ -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'),
),
]

View File

@ -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,