diff --git a/InvenTree/build/migrations/0043_build_project_code.py b/InvenTree/build/migrations/0043_build_project_code.py new file mode 100644 index 0000000000..e436c61f41 --- /dev/null +++ b/InvenTree/build/migrations/0043_build_project_code.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.19 on 2023-05-13 12:04 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0019_projectcode_metadata'), + ('build', '0042_alter_build_notes'), + ] + + operations = [ + migrations.AddField( + model_name='build', + name='project_code', + field=models.ForeignKey(blank=True, help_text='Project code for this build order', null=True, on_delete=django.db.models.deletion.SET_NULL, to='common.projectcode', verbose_name='Project Code'), + ), + ] diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index dcb31aa0e6..c207cc481f 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -61,6 +61,7 @@ class Build(MPTTModel, InvenTree.models.InvenTreeBarcodeMixin, InvenTree.models. issued_by: User that issued the build responsible: User (or group) responsible for completing the build priority: Priority of the build + project_code: Reference to ProjectCode instance """ class Meta: @@ -297,6 +298,14 @@ class Build(MPTTModel, InvenTree.models.InvenTreeBarcodeMixin, InvenTree.models. help_text=_('Priority of this build order') ) + project_code = models.ForeignKey( + 'common.ProjectCode', + on_delete=models.SET_NULL, + blank=True, null=True, + verbose_name=_('Project Code'), + help_text=_('Project code for this build order'), + ) + def sub_builds(self, cascade=True): """Return all Build Order objects under this one.""" if cascade: