From 3085db44afe520aeba4125d5b732838e323148da Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 27 Jun 2019 21:44:40 +1000 Subject: [PATCH] Add 'reference' field to BOM item model --- .../migrations/0012_auto_20190627_2144.py | 23 +++++++++++++++++++ InvenTree/part/models.py | 11 +++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 InvenTree/part/migrations/0012_auto_20190627_2144.py diff --git a/InvenTree/part/migrations/0012_auto_20190627_2144.py b/InvenTree/part/migrations/0012_auto_20190627_2144.py new file mode 100644 index 0000000000..ffd574b61d --- /dev/null +++ b/InvenTree/part/migrations/0012_auto_20190627_2144.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.2 on 2019-06-27 11:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0011_part_revision'), + ] + + operations = [ + migrations.AddField( + model_name='bomitem', + name='reference', + field=models.CharField(blank=True, help_text='BOM item reference', max_length=500), + ), + migrations.AlterField( + model_name='bomitem', + name='note', + field=models.CharField(blank=True, help_text='BOM item notes', max_length=500), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 48e8dc7906..5f31e8a912 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -843,15 +843,19 @@ class Part(models.Model): 'Part', 'Description', 'Quantity', + 'Overage', + 'Reference', 'Note', ]) - for it in self.bom_items.all(): + for it in self.bom_items.all().order_by('id'): line = [] line.append(it.sub_part.full_name) line.append(it.sub_part.description) line.append(it.quantity) + line.append(it.overage) + line.append(it.reference) line.append(it.note) data.append(line) @@ -969,6 +973,7 @@ class BomItem(models.Model): part: Link to the parent part (the part that will be produced) sub_part: Link to the child part (the part that will be consumed) quantity: Number of 'sub_parts' consumed to produce one 'part' + reference: BOM reference field (e.g. part designators) overage: Estimated losses for a Build. Can be expressed as absolute value (e.g. '7') or a percentage (e.g. '2%') note: Note field for this BOM item """ @@ -1001,8 +1006,10 @@ class BomItem(models.Model): help_text='Estimated build wastage quantity (absolute or percentage)' ) + reference = models.CharField(max_length=500, blank=True, help_text='BOM item reference') + # Note attached to this BOM line item - note = models.CharField(max_length=100, blank=True, help_text='BOM item notes') + note = models.CharField(max_length=500, blank=True, help_text='BOM item notes') def clean(self): """ Check validity of the BomItem model.