diff --git a/InvenTree/InvenTree/models.py b/InvenTree/InvenTree/models.py
index bbac3a9b03..8be2db7c52 100644
--- a/InvenTree/InvenTree/models.py
+++ b/InvenTree/InvenTree/models.py
@@ -13,6 +13,7 @@ class Company(models.Model):
abstract = True
name = models.CharField(max_length=100, unique=True)
+ description = models.CharField(max_length=500, blank=True)
website = models.URLField(blank=True)
address = models.CharField(max_length=200,
blank=True)
diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py
index f5b3b94f9b..0c9c5465eb 100644
--- a/InvenTree/InvenTree/urls.py
+++ b/InvenTree/InvenTree/urls.py
@@ -11,7 +11,8 @@ from part.urls import part_urls
from stock.urls import stock_api_urls, stock_api_loc_urls
from stock.urls import stock_urls
-from supplier.urls import cust_urls, manu_urls, supplier_part_urls, price_break_urls, supplier_urls
+from supplier.urls import supplier_api_urls, supplier_api_part_urls
+from supplier.urls import supplier_urls
from django.conf import settings
from django.conf.urls.static import static
@@ -41,11 +42,11 @@ apipatterns = [
url(r'^bom/', include(bom_api_urls)),
# Supplier URLs
- url(r'^supplier/', include(supplier_urls)),
- url(r'^supplier-part/', include(supplier_part_urls)),
- url(r'^price-break/', include(price_break_urls)),
- url(r'^manufacturer/', include(manu_urls)),
- url(r'^customer/', include(cust_urls)),
+ url(r'^supplier/', include(supplier_api_urls)),
+ url(r'^supplier-part/', include(supplier_api_part_urls)),
+ #url(r'^price-break/', include(price_break_urls)),
+ #url(r'^manufacturer/', include(manu_urls)),
+ #url(r'^customer/', include(cust_urls)),
# Tracking URLs
#url(r'^track/', include(part_track_urls)),
@@ -69,6 +70,8 @@ urlpatterns = [
url(r'^part/', include(part_urls)),
url(r'^stock/', include(stock_urls)),
+ url(r'^supplier/', include(supplier_urls)),
+
url(r'^api-doc/', include_docs_urls(title='InvenTree API')),
url(r'^admin/', admin.site.urls),
diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html
index 6e34cc4fd9..da475651b4 100644
--- a/InvenTree/part/templates/part/detail.html
+++ b/InvenTree/part/templates/part/detail.html
@@ -9,10 +9,18 @@ Used in {{ part.usedInCount }} other parts.
There are {{ part.stock }} units in stock.
+
+{% if part.supplier_parts.all|length > 0 %}
+This part is available from {{ part.supplier_parts.all|length }} suppliers.
+{% else %}
+There are no suppliers defined for this part.
+{% endif %}
+
{% if part.trackable %}
Part tracking
{% else %}
{{ part.name }} does not have part tracking enabled
{% endif %}
+
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html
index 04cac037f9..480c538e44 100644
--- a/InvenTree/part/templates/part/stock.html
+++ b/InvenTree/part/templates/part/stock.html
@@ -20,7 +20,9 @@ Total in stock: {{ part.stock }}
{{ stock.location.name }} |
{% if stock.supplier_part %}
+
{{ stock.supplier_part.supplier.name }} | {{ stock.supplier_part.SKU }}
+
{% endif %}
|
{% if stock.stocktake_date %}{{ stock.stocktake_date }}{% endif %} |
diff --git a/InvenTree/part/templates/part/supplier.html b/InvenTree/part/templates/part/supplier.html
new file mode 100644
index 0000000000..ae72958fce
--- /dev/null
+++ b/InvenTree/part/templates/part/supplier.html
@@ -0,0 +1,24 @@
+{% extends "part/part_base.html" %}
+
+{% block details %}
+
+{% if part.supplier_parts.all|length > 0 %}
+
+{% else %}
+There are no suppliers defined for this part, sorry!
+{% endif %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/part/urls.py b/InvenTree/part/urls.py
index 5943401302..96f05f5bba 100644
--- a/InvenTree/part/urls.py
+++ b/InvenTree/part/urls.py
@@ -42,6 +42,7 @@ part_detail_urls = [
url(r'^track/?', views.track, name='part-track'),
url(r'^bom/?', views.bom, name='part-bom'),
url(r'^stock/?', views.stock, name='part-stock'),
+ url(r'^suppliers/?', views.suppliers, name='part-suppliers'),
url('', views.detail, name='part-detail'),
]
diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py
index 47eea2608a..2091ee2387 100644
--- a/InvenTree/part/views.py
+++ b/InvenTree/part/views.py
@@ -64,3 +64,8 @@ def track(request, pk):
return render(request, 'part/track.html', {'part': part})
+
+def suppliers(request, pk):
+ part = get_object_or_404(Part, pk=pk)
+
+ return render(request, 'part/supplier.html', {'part' : part})
diff --git a/InvenTree/stock/templates/stock/detail.html b/InvenTree/stock/templates/stock/detail.html
index e9b758c8d2..c2bb1dd036 100644
--- a/InvenTree/stock/templates/stock/detail.html
+++ b/InvenTree/stock/templates/stock/detail.html
@@ -7,7 +7,7 @@
- Part: {{ item.part.name }}
{% if item.supplier_part %}
-- Supplier Part: {{ item.supplier_part.supplier.name }} | {{ item.supplier_part.SKU }}
+- Supplier Part: {{ item.supplier_part.supplier.name }} | {{ item.supplier_part.SKU }}
{% endif %}
- Quantity: {{ item.quantity }}
{% if item.stocktake_date %}
diff --git a/InvenTree/stock/urls.py b/InvenTree/stock/urls.py
index 911fa306c9..3c951f29e5 100644
--- a/InvenTree/stock/urls.py
+++ b/InvenTree/stock/urls.py
@@ -38,7 +38,7 @@ stock_urls = [
# Individual stock items
url(r'^(?P\d+)/', include(stock_detail_urls)),
- url('list', views.index, name='stock=index'),
+ url('list', views.index, name='stock-index'),
# Redirect any other patterns
url(r'^.*$', RedirectView.as_view(url='list', permanent=False), name='stock-index'),
diff --git a/InvenTree/supplier/models.py b/InvenTree/supplier/models.py
index 31f4c67d98..1a3a10b86a 100644
--- a/InvenTree/supplier/models.py
+++ b/InvenTree/supplier/models.py
@@ -40,7 +40,10 @@ class SupplierPart(models.Model):
part = models.ForeignKey(Part, null=True, blank=True, on_delete=models.CASCADE,
related_name='supplier_parts')
- supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE)
+ supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE,
+ related_name = 'parts')
+
+
SKU = models.CharField(max_length=100)
manufacturer = models.ForeignKey(Manufacturer, blank=True, null=True, on_delete=models.CASCADE)
diff --git a/InvenTree/supplier/templates/supplier/detail.html b/InvenTree/supplier/templates/supplier/detail.html
new file mode 100644
index 0000000000..e3cd207e0c
--- /dev/null
+++ b/InvenTree/supplier/templates/supplier/detail.html
@@ -0,0 +1,34 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+
+- Name: {{ supplier.name }}
+- Description: {{ supplier.description }}
+- Website: {{ supplier.website }}
+- Contact: {{ supplier.contact }}
+
+
+{% if supplier.parts.all|length > 0 %}
+
+
+ Part |
+ SKU |
+ Manufacturer |
+ MPN |
+ URL |
+
+{% for part in supplier.parts.all %}
+
+ {{ part.part.name }} |
+ {{ part.SKU }} |
+ Manufacturer name goes here |
+ MPN goes here |
+ {{ part.URL }} |
+{% endfor %}
+
+{% else %}
+There are currently no parts sourced from this supplier.
+{% endif %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/supplier/templates/supplier/index.html b/InvenTree/supplier/templates/supplier/index.html
new file mode 100644
index 0000000000..b266c9e7dd
--- /dev/null
+++ b/InvenTree/supplier/templates/supplier/index.html
@@ -0,0 +1,19 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+
+
+ Supplier |
+ Description |
+ URL |
+
+{% for supplier in suppliers %}
+
+ {{ supplier.name }} |
+ {{ supplier.description }} |
+ {{ supplier.website }} |
+
+{% endfor %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/supplier/templates/supplier/partdetail.html b/InvenTree/supplier/templates/supplier/partdetail.html
new file mode 100644
index 0000000000..d561c4c395
--- /dev/null
+++ b/InvenTree/supplier/templates/supplier/partdetail.html
@@ -0,0 +1,14 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/supplier/urls.py b/InvenTree/supplier/urls.py
index 2fa2be08dd..bc7f0d4711 100644
--- a/InvenTree/supplier/urls.py
+++ b/InvenTree/supplier/urls.py
@@ -1,4 +1,5 @@
from django.conf.urls import url
+from django.views.generic.base import RedirectView
from . import views
from . import api
@@ -21,7 +22,7 @@ manu_urls = [
url(r'^$', api.ManufacturerList.as_view())
]
-supplier_part_urls = [
+supplier_api_part_urls = [
url(r'^(?P[0-9]+)/?$', api.SupplierPartDetail.as_view(), name='supplierpart-detail'),
url(r'^\?.*/?$', api.SupplierPartList.as_view()),
@@ -35,7 +36,7 @@ price_break_urls = [
url(r'^$', api.SupplierPriceBreakList.as_view())
]
-supplier_urls = [
+supplier_api_urls = [
# Display details of a supplier
url(r'^(?P[0-9]+)/$', api.SupplierDetail.as_view(), name='supplier-detail'),
@@ -44,3 +45,12 @@ supplier_urls = [
url(r'^\?.*/?$', api.SupplierList.as_view()),
url(r'^$', api.SupplierList.as_view())
]
+
+supplier_urls = [
+ url(r'^(?P\d+)/', views.detail, name='supplier-detail'),
+ url(r'^part/(?P\d+)/', views.partDetail, name='supplier-part-detail'),
+ url(r'', views.index, name='supplier-index'),
+
+ # Redirect any other patterns
+ url(r'^.*$', RedirectView.as_view(url='', permanent=False), name='supplier-index'),
+]
\ No newline at end of file
diff --git a/InvenTree/supplier/views.py b/InvenTree/supplier/views.py
index e69de29bb2..a6fd62000f 100644
--- a/InvenTree/supplier/views.py
+++ b/InvenTree/supplier/views.py
@@ -0,0 +1,34 @@
+from django.http import HttpResponse
+from django.template import loader
+
+from django.shortcuts import get_object_or_404, render
+
+from .models import Supplier, SupplierPart
+
+def index(request):
+ """ The supplier index page simply displays all the suppliers
+ """
+
+ suppliers = Supplier.objects.order_by('name')
+
+ return render(request, 'supplier/index.html', {'suppliers' : suppliers})
+
+
+def detail(request, pk):
+ """ The supplier detail page shown detailed information
+ on a particular supplier
+ """
+
+ supplier = get_object_or_404(Supplier, pk=pk)
+
+ return render(request, 'supplier/detail.html', {'supplier' : supplier})
+
+
+def partDetail(request, pk):
+ """ The supplier part-detail page shows detailed information
+ on a particular supplier part
+ """
+
+ part = get_object_or_404(SupplierPart, pk=pk)
+
+ return render(request, 'supplier/partdetail.html', {'part': part})
\ No newline at end of file