diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 04d1978745..18267f33c4 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -177,7 +177,10 @@ class AjaxCreateView(AjaxMixin, CreateView): # Return the PK of the newly-created object data['pk'] = obj.pk - data['url'] = obj.get_absolute_url() + try: + data['url'] = obj.get_absolute_url() + except AttributeError: + pass return self.renderJsonResponse(request, form, data) @@ -223,7 +226,11 @@ class AjaxUpdateView(AjaxMixin, UpdateView): # Include context data about the updated object data['pk'] = obj.id - data['url'] = obj.get_absolute_url() + + try: + data['url'] = obj.get_absolute_url() + except AttributeError: + pass return self.renderJsonResponse(request, form, data) diff --git a/InvenTree/company/templates/company/partdetail.html b/InvenTree/company/templates/company/partdetail.html index 644dc5760e..a67e0fbf2d 100644 --- a/InvenTree/company/templates/company/partdetail.html +++ b/InvenTree/company/templates/company/partdetail.html @@ -23,59 +23,66 @@
Supplier | {{ part.supplier.name }} | ||||||||||||||||||||||||||||||||||||||||||||||||||
SKU | {{ part.SKU }} | ||||||||||||||||||||||||||||||||||||||||||||||||||
Internal Part | -
- {% if part.part %}
- {{ part.part.name }}
+
+
+
+
+
+
+
+
+
- - Price Breaks- -
diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py
index bba8c3e973..0363b4ab37 100644
--- a/InvenTree/part/forms.py
+++ b/InvenTree/part/forms.py
@@ -9,7 +9,8 @@ from InvenTree.forms import HelperForm
from django import forms
-from .models import Part, PartCategory, BomItem
+from .models import Part, PartCategory, PartAttachment
+from .models import BomItem
from .models import SupplierPart
@@ -44,6 +45,18 @@ class BomExportForm(HelperForm):
]
+class EditPartAttachmentForm(HelperForm):
+ """ Form for editing a PartAttachment object """
+
+ class Meta:
+ model = PartAttachment
+ fields = [
+ 'part',
+ 'attachment',
+ 'comment'
+ ]
+
+
class EditPartForm(HelperForm):
""" Form for editing a Part object """
diff --git a/InvenTree/part/migrations/0012_part_active.py b/InvenTree/part/migrations/0012_part_active.py
index c2f3b55f6c..87929e2f85 100644
--- a/InvenTree/part/migrations/0012_part_active.py
+++ b/InvenTree/part/migrations/0012_part_active.py
@@ -14,5 +14,10 @@ class Migration(migrations.Migration):
model_name='part',
name='active',
field=models.BooleanField(default=True, help_text='Is this part active?'),
+ ),
+ migrations.AddField(
+ model_name='partattachment',
+ name='comment',
+ field=models.CharField(blank=True, help_text='File comment', max_length=100),
),
]
diff --git a/InvenTree/part/migrations/0014_partattachment_comment.py b/InvenTree/part/migrations/0014_partattachment_comment.py
deleted file mode 100644
index a51f588a59..0000000000
--- a/InvenTree/part/migrations/0014_partattachment_comment.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by Django 2.2 on 2019-04-30 23:34
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('part', '0013_auto_20190429_2229'),
- ]
-
- operations = [
- migrations.AddField(
- model_name='partattachment',
- name='comment',
- field=models.CharField(blank=True, help_text='Attachment description', 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
diff --git a/InvenTree/part/templates/part/attachment_delete.html b/InvenTree/part/templates/part/attachment_delete.html
new file mode 100644
index 0000000000..db98b7f6d6
--- /dev/null
+++ b/InvenTree/part/templates/part/attachment_delete.html
@@ -0,0 +1,3 @@
+Are you sure you wish to delete this attachment?
+ +This will remove the file '{{ attachment.basename }}'. \ No newline at end of file diff --git a/InvenTree/part/templates/part/attachments.html b/InvenTree/part/templates/part/attachments.html new file mode 100644 index 0000000000..24c69f23f7 --- /dev/null +++ b/InvenTree/part/templates/part/attachments.html @@ -0,0 +1,62 @@ +{% extends "part/part_base.html" %} +{% load static %} + +{% block details %} + +{% include 'part/tabs.html' with tab='attachments' %} + + Attachments+ +
+
+
+
+
|