Separate views for customer / supplier / manufacturer

(cherry picked from commit 9e9e29679d)
This commit is contained in:
Oliver Walters 2020-04-13 12:47:06 +10:00
parent edfb19db13
commit 67d9d2bb04
5 changed files with 49 additions and 7 deletions

View File

@ -40,7 +40,7 @@ function loadCompanyTable(table, url, options={}) {
var html = imageHoverIcon(row.image) + renderLink(value, row.url); var html = imageHoverIcon(row.image) + renderLink(value, row.url);
if (row.is_customer) { if (row.is_customer) {
html += `<span title='Customer' class='fas fa-user label-right'></span>`; html += `<span title='Customer' class='fas fa-user-tie label-right'></span>`;
} }
if (row.is_manufacturer) { if (row.is_manufacturer) {

View File

@ -9,12 +9,12 @@ InvenTree | {% trans "Supplier List" %}
{% block content %} {% block content %}
<h3>{% trans "Supplier List" %}</h3> <h3>{{ title }}</h3>
<hr> <hr>
<div id='button-toolbar'> <div id='button-toolbar'>
<div class='btn-group'> <div class='btn-group'>
<button type='button' class="btn btn-success" id='new-company' title='Add new supplier'>{% trans "New Supplier" %}</button> <button type='button' class="btn btn-success" id='new-company'>{{ new_button_text }}</button>
</div> </div>
</div> </div>
@ -35,6 +35,9 @@ InvenTree | {% trans "Supplier List" %}
loadCompanyTable("#company-table", "{% url 'api-company-list' %}", loadCompanyTable("#company-table", "{% url 'api-company-list' %}",
{ {
params: {
{% for key,value in filters.items %}{{ key }}: "{{ value }}",{% endfor %}
}
} }
); );

View File

@ -33,10 +33,12 @@ company_urls = [
url(r'^(?P<pk>\d+)/', include(company_detail_urls)), url(r'^(?P<pk>\d+)/', include(company_detail_urls)),
url(r'', views.CompanyIndex.as_view(), name='company-index'), url(r'suppliers/', views.CompanyIndex.as_view(), name='supplier-index'),
url(r'manufacturers/', views.CompanyIndex.as_view(), name='manufacturer-index'),
url(r'customers/', views.CompanyIndex.as_view(), name='customer-index'),
# Redirect any other patterns to the 'company' index which displays all companies # Redirect any other patterns to the 'company' index which displays all companies
url(r'^.*$', RedirectView.as_view(url='', permanent=False), name='company-index'), url(r'^.*$', views.CompanyIndex.as_view(), name='company-index'),
] ]
price_break_urls = [ price_break_urls = [

View File

@ -39,6 +39,37 @@ class CompanyIndex(ListView):
context_object_name = 'companies' context_object_name = 'companies'
paginate_by = 50 paginate_by = 50
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
url = self.request.path
print(url)
print(reverse('supplier-index'))
print(reverse('manufacturer-index'))
print(reverse('customer-index'))
if url == reverse('supplier-index'):
ctx["title"] = _("Suppliers")
ctx['new_button_text'] = _("New Supplier")
ctx["filters"] = {"is_supplier": "true"}
elif url == reverse('manufacturer-index'):
ctx["title"] = _("Manufacturers")
ctx['new_button_text'] = _("New Manufacturer")
ctx["filters"] = {"is_manufacturer": "true"}
elif url == reverse('customer-index'):
ctx["title"] = _("Customers")
ctx['new_button_text'] = _("New Customer")
ctx["filters"] = {"is_customer": "true"}
else:
ctx["title"] = _("Companies")
ctx["new_button_text"] = _("New Company")
ctx["filters"] = {}
return ctx
def get_queryset(self): def get_queryset(self):
""" Retrieve the Company queryset based on HTTP request parameters. """ Retrieve the Company queryset based on HTTP request parameters.

View File

@ -13,11 +13,17 @@
<li class='nav navbar-nav'> <li class='nav navbar-nav'>
<a class='dropdown-toggle' data-toggle='dropdown' href='#'><span class='fas fa-shopping-cart icon-header'></span>{% trans "Buy" %}</a> <a class='dropdown-toggle' data-toggle='dropdown' href='#'><span class='fas fa-shopping-cart icon-header'></span>{% trans "Buy" %}</a>
<ul class='dropdown-menu'> <ul class='dropdown-menu'>
<li><a href="{% url 'company-index' %}"><span class='fas fa-building icon-header'></span>{% trans "Suppliers" %}</a></li> <li><a href="{% url 'supplier-index' %}"><span class='fas fa-building icon-header'></span>{% trans "Suppliers" %}</a></li>
<li><a href="{% url 'company-index' %}"><span class='fas fa-industry icon-header'></span>{% trans "Manufacturers" %}</a></li> <li><a href="{% url 'manufacturer-index' %}"><span class='fas fa-industry icon-header'></span>{% trans "Manufacturers" %}</a></li>
<li><a href="{% url 'po-index' %}"><span class='fas fa-list icon-header'></span>{% trans "Purchase Orders" %}</a></li> <li><a href="{% url 'po-index' %}"><span class='fas fa-list icon-header'></span>{% trans "Purchase Orders" %}</a></li>
</ul> </ul>
</li> </li>
<li class='nav navbar-nav'>
<a class='dropdown-toggle' data-toggle='dropdown' href='#'><span class='fas fa-truck icon-header'></span>{% trans "Sell" %}</a>
<ul class='dropdown-menu'>
<li><a href="{% url 'customer-index' %}"><span class='fas fa-user-tie icon-header'></span>{% trans "Customers" %}</a>
</ul>
</li>
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
{% include "search_form.html" %} {% include "search_form.html" %}