diff --git a/InvenTree/company/templates/company/detail_part.html b/InvenTree/company/templates/company/detail_part.html new file mode 100644 index 0000000000..d7e45ecb82 --- /dev/null +++ b/InvenTree/company/templates/company/detail_part.html @@ -0,0 +1,36 @@ +{% extends "company/company_base.html" %} + +{% block details %} + +{% include 'company/tabs.html' with tab='parts' %} + +

Company Parts

+ + + + + + + + +{% for part in company.parts.all %} + + + + + + +{% endfor %} +
SKUPartMPNURL
{{ part.SKU }} + {% if part.part %} + {{ part.part.name }} + {% endif %} + {{ part.manufacturer_string }}{{ part.URL }}
+ +
+ + + +
+ +{% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/partdetail.html b/InvenTree/company/templates/company/partdetail.html index fbef8b28c9..41a2a8652a 100644 --- a/InvenTree/company/templates/company/partdetail.html +++ b/InvenTree/company/templates/company/partdetail.html @@ -6,7 +6,7 @@ - + {% endif %} {% if part.manufacturer %} - + {% endif %}
SKU{{ part.SKU }}
Supplier{{ part.supplier.name }}
Supplier{{ part.supplier.name }}
Parent Part @@ -22,7 +22,7 @@
Description{{ part.description }}
Manufacturer{% if part.manufacturer %}{{ part.manufacturer.name }}{% endif %}
Manufacturer{{ part.manufacturer }}
MPN{{ part.MPN }}
diff --git a/InvenTree/company/templates/company/tabs.html b/InvenTree/company/templates/company/tabs.html index 5ee86df1be..4eaab521ba 100644 --- a/InvenTree/company/templates/company/tabs.html +++ b/InvenTree/company/templates/company/tabs.html @@ -4,7 +4,7 @@ {% if company.is_supplier %} - Supplier Parts {{ company.part_count }} + Supplier Parts {{ company.part_count }} Purchase Orders diff --git a/InvenTree/company/urls.py b/InvenTree/company/urls.py index e83b587c70..5defa50568 100644 --- a/InvenTree/company/urls.py +++ b/InvenTree/company/urls.py @@ -10,6 +10,9 @@ company_detail_urls = [ # url(r'orders/?', views.CompanyDetail.as_view(template_name='company/orders.html'), name='company-detail-orders'), + url(r'parts/?', views.CompanyDetail.as_view(template_name='company/detail_part.html'), name='company-detail-parts'), + + # Any other URL url(r'^.*$', views.CompanyDetail.as_view(), name='company-detail'), ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index e938c47733..cf68d66257 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -403,6 +403,18 @@ class SupplierPart(models.Model): # lead time for parts that cannot be delivered immediately lead_time = models.DurationField(blank=True, null=True) + @property + def manufacturer_string(self): + + items = [] + + if self.manufacturer: + items.append(self.manufacturer) + if self.MPN: + items.append(self.MPN) + + return ' | '.join(items) + def __str__(self): return "{sku} - {supplier}".format( sku=self.SKU, diff --git a/InvenTree/part/templates/part/supplier.html b/InvenTree/part/templates/part/supplier.html index 7ccc209723..27483a4f55 100644 --- a/InvenTree/part/templates/part/supplier.html +++ b/InvenTree/part/templates/part/supplier.html @@ -17,10 +17,7 @@ {{ spart.SKU }} {{ spart.supplier.name }} - - {% if spart.manufacturer %}{{ spart.manufacturer.name }}{% endif %} - {% if spart.MPN %} | {{ spart.MPN }}{% endif %} - + {{ spart.manufacturer_string }} {% if spart.URL %} {{ spart.URL }} diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index 9093ca326b..883d09e1cf 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -7,6 +7,7 @@ from django.http import HttpResponseRedirect from django.views.generic import DetailView, ListView from django.views.generic.edit import UpdateView, DeleteView, CreateView +from company.models import Company from .models import PartCategory, Part, BomItem from .models import SupplierPart @@ -226,7 +227,7 @@ class SupplierPartCreate(CreateView): part_id = self.request.GET.get('part', None) if supplier_id: - initials['supplier'] = get_object_or_404(Supplier, pk=supplier_id) + initials['supplier'] = get_object_or_404(Company, pk=supplier_id) # TODO # self.fields['supplier'].disabled = True if part_id: