Add 'batch' field to BuildOutput object

This 'batch' output will be copied to any parts produced as part of this build
This commit is contained in:
Oliver 2018-04-17 18:29:40 +10:00
parent 982803a0a7
commit 256f8eb924
3 changed files with 34 additions and 1 deletions

View File

@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.contrib import admin
from .models import Build
from .models import Build, BuildOutput
class BuildAdmin(admin.ModelAdmin):
@ -11,4 +11,10 @@ class BuildAdmin(admin.ModelAdmin):
list_display = ('status', )
class BuildOutputAdmin(admin.ModelAdmin):
list_display = ('build', 'part', 'batch', 'quantity', )
admin.site.register(Build, BuildAdmin)
admin.site.register(BuildOutput, BuildOutputAdmin)

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.12 on 2018-04-17 08:29
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('build', '0004_auto_20180417_0657'),
]
operations = [
migrations.AddField(
model_name='buildoutput',
name='batch',
field=models.CharField(blank=True, help_text='Batch code for this build output', max_length=100),
),
]

View File

@ -40,12 +40,19 @@ class BuildOutput(models.Model):
A build output represents a single build part/quantity combination
"""
batch = models.CharField(max_length=100, blank=True,
help_text='Batch code for this build output')
# Reference to the build object of which this output is a part
# A build can have multiple outputs
build = models.ForeignKey(Build, on_delete=models.CASCADE,
related_name='outputs')
# A reference to the part being built
part = models.ForeignKey(Part, on_delete=models.CASCADE,
related_name='builds')
# How many parts to build?
quantity = models.PositiveIntegerField(default=1,
validators=[MinValueValidator(1)],
help_text='Number of parts to build')