Add 'project_code' field to Build model

This commit is contained in:
Oliver 2023-05-13 22:08:05 +10:00
parent 634daa2161
commit c540004a60
2 changed files with 29 additions and 0 deletions

View File

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

View File

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