mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add part detail page for company / supplier
This commit is contained in:
parent
4ebd8cd6b1
commit
ac3de4ce3d
36
InvenTree/company/templates/company/detail_part.html
Normal file
36
InvenTree/company/templates/company/detail_part.html
Normal file
@ -0,0 +1,36 @@
|
||||
{% extends "company/company_base.html" %}
|
||||
|
||||
{% block details %}
|
||||
|
||||
{% include 'company/tabs.html' with tab='parts' %}
|
||||
|
||||
<h3>Company Parts</h3>
|
||||
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<th>SKU</th>
|
||||
<th>Part</th>
|
||||
<th>MPN</th>
|
||||
<th>URL</th>
|
||||
</tr>
|
||||
{% for part in company.parts.all %}
|
||||
<tr>
|
||||
<td><a href="{% url 'supplier-part-detail' part.id %}">{{ part.SKU }}</a></td>
|
||||
<td>
|
||||
{% if part.part %}
|
||||
<a href="{% url 'part-suppliers' part.part.id %}">{{ part.part.name }}</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ part.manufacturer_string }}</td>
|
||||
<td>{{ part.URL }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<div class='container-fluid'>
|
||||
<a href="{% url 'supplier-part-create' %}?supplier={{ company.id }}">
|
||||
<button class="btn btn-success">New Supplier Part</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
@ -6,7 +6,7 @@
|
||||
|
||||
<table class="table">
|
||||
<tr><td>SKU</td><td>{{ part.SKU }}</tr></tr>
|
||||
<tr><td>Supplier</td><td><a href="{% url 'company-detail' part.supplier.id %}">{{ part.supplier.name }}</a></td></tr>
|
||||
<tr><td>Supplier</td><td><a href="{% url 'company-detail-parts' part.supplier.id %}">{{ part.supplier.name }}</a></td></tr>
|
||||
<tr>
|
||||
<td>Parent Part</td>
|
||||
<td>
|
||||
@ -22,7 +22,7 @@
|
||||
<tr><td>Description</td><td>{{ part.description }}</td></tr>
|
||||
{% endif %}
|
||||
{% if part.manufacturer %}
|
||||
<tr><td>Manufacturer</td><td>{% if part.manufacturer %}{{ part.manufacturer.name }}{% endif %}</td></tr>
|
||||
<tr><td>Manufacturer</td><td>{{ part.manufacturer }}</td></tr>
|
||||
<tr><td>MPN</td><td>{{ part.MPN }}</td></tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
|
@ -4,7 +4,7 @@
|
||||
</li>
|
||||
{% if company.is_supplier %}
|
||||
<li{% if tab == 'parts' %} class='active'{% endif %}>
|
||||
<a href="{% url 'company-detail' company.id %}">Supplier Parts <span class='badge'>{{ company.part_count }}</span></a>
|
||||
<a href="{% url 'company-detail-parts' company.id %}">Supplier Parts <span class='badge'>{{ company.part_count }}</span></a>
|
||||
</li>
|
||||
<li{% if tab == 'po' %} class='active'{% endif %}>
|
||||
<a href="#">Purchase Orders</a>
|
||||
|
@ -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'),
|
||||
]
|
||||
|
||||
|
@ -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,
|
||||
|
@ -17,10 +17,7 @@
|
||||
<tr>
|
||||
<td><a href="{% url 'supplier-part-detail' spart.id %}">{{ spart.SKU }}</a></td>
|
||||
<td><a href="{% url 'company-detail' spart.supplier.id %}">{{ spart.supplier.name }}</a></td>
|
||||
<td>
|
||||
{% if spart.manufacturer %}{{ spart.manufacturer.name }}{% endif %}
|
||||
{% if spart.MPN %} | {{ spart.MPN }}{% endif %}
|
||||
</td>
|
||||
<td>{{ spart.manufacturer_string }}</td>
|
||||
<td>
|
||||
{% if spart.URL %}
|
||||
<a href="{{ spart.URL }}">{{ spart.URL }}</a>
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user