Adds 'issued_by' and 'responsible' field to BuildOrder

- issued_by is a user
- responsible is a user or a group
This commit is contained in:
Oliver Walters 2021-02-16 15:40:27 +11:00
parent 6cc0880b4a
commit 31a8c94d2f
3 changed files with 49 additions and 0 deletions

View File

@ -53,6 +53,8 @@ class EditBuildForm(HelperForm):
'parent',
'sales_order',
'link',
'issued_by',
'responsible',
]

View File

@ -0,0 +1,27 @@
# Generated by Django 3.0.7 on 2021-02-16 04:39
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('users', '0005_owner_model'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('build', '0025_build_target_date'),
]
operations = [
migrations.AddField(
model_name='build',
name='issued_by',
field=models.ForeignKey(blank=True, help_text='User who issued this build order', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='builds_issued', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='build',
name='responsible',
field=models.ForeignKey(blank=True, help_text='User responsible for this build order', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='builds_responsible', to='users.Owner'),
),
]

View File

@ -33,6 +33,7 @@ import InvenTree.fields
from stock import models as StockModels
from part import models as PartModels
from users import models as UserModels
class Build(MPTTModel):
@ -53,6 +54,9 @@ class Build(MPTTModel):
completion_date: Date the build was completed (or, if incomplete, the expected date of completion)
link: External URL for extra information
notes: Text notes
completed_by: User that completed the build
issued_by: User that issued the build
responsible: User (or group) responsible for completing the build
"""
OVERDUE_FILTER = Q(status__in=BuildStatus.ACTIVE_CODES) & ~Q(target_date=None) & Q(target_date__lte=datetime.now().date())
@ -215,6 +219,22 @@ class Build(MPTTModel):
related_name='builds_completed'
)
issued_by = models.ForeignKey(
User,
on_delete=models.SET_NULL,
blank=True, null=True,
help_text=_('User who issued this build order'),
related_name='builds_issued',
)
responsible = models.ForeignKey(
UserModels.Owner,
on_delete=models.SET_NULL,
blank=True, null=True,
help_text=_('User responsible for this build order'),
related_name='builds_responsible',
)
link = InvenTree.fields.InvenTreeURLField(
verbose_name=_('External Link'),
blank=True, help_text=_('Link to external URL')