From ad6f4e19b123d02a36146bde280f13abdffb05fe Mon Sep 17 00:00:00 2001 From: Oliver Walters <oliver.henry.walters@gmail.com> Date: Sun, 28 Apr 2019 22:40:17 +1000 Subject: [PATCH] Add 'comment' field to part attachment model --- .../migrations/0012_partattachment_comment.py | 18 ++++++++++++++++++ InvenTree/part/models.py | 15 +++------------ 2 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 InvenTree/part/migrations/0012_partattachment_comment.py diff --git a/InvenTree/part/migrations/0012_partattachment_comment.py b/InvenTree/part/migrations/0012_partattachment_comment.py new file mode 100644 index 0000000000..a1a0057d1b --- /dev/null +++ b/InvenTree/part/migrations/0012_partattachment_comment.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2 on 2019-04-28 12:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0011_auto_20190428_0841'), + ] + + operations = [ + migrations.AddField( + model_name='partattachment', + name='comment', + field=models.CharField(blank=True, help_text='File comment', max_length=100), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 19682929cf..ab83b584cd 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -125,7 +125,7 @@ class Part(models.Model): IPN = models.CharField(max_length=100, blank=True, help_text='Internal Part Number') # Provide a URL for an external link - URL = models.URLField(blank=True, help_text='Link to external URL') + URL = models.URLField(blank=True, help_text='Link to extenal URL') # Part category - all parts must be assigned to a category category = models.ForeignKey(PartCategory, related_name='parts', @@ -307,12 +307,6 @@ class Part(models.Model): def used_in_count(self): return self.used_in.count() - def required_parts(self): - parts = [] - for bom in self.bom_items.all(): - parts.append(bom.sub_part) - return parts - @property def supplier_count(self): # Return the number of supplier parts available for this part @@ -366,7 +360,7 @@ class PartAttachment(models.Model): attachment = models.FileField(upload_to=attach_file, null=True, blank=True) - comment = models.CharField(max_length=100, blank=True, help_text="Attachment description") + comment = models.CharField(max_length=100, blank=True, help_text='File comment') @property def basename(self): @@ -407,11 +401,8 @@ class BomItem(models.Model): - A part cannot refer to a part which refers to it """ - if self.part is None or self.sub_part is None: - # Field validation will catch these None values - pass # A part cannot refer to itself in its BOM - elif self.part == self.sub_part: + if self.part == self.sub_part: raise ValidationError({'sub_part': _('Part cannot be added to its own Bill of Materials')}) # Test for simple recursion