mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Separate views for customer / supplier / manufacturer
(cherry picked from commit 9e9e29679d
)
This commit is contained in:
parent
edfb19db13
commit
67d9d2bb04
@ -40,7 +40,7 @@ function loadCompanyTable(table, url, options={}) {
|
||||
var html = imageHoverIcon(row.image) + renderLink(value, row.url);
|
||||
|
||||
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) {
|
||||
|
@ -9,12 +9,12 @@ InvenTree | {% trans "Supplier List" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h3>{% trans "Supplier List" %}</h3>
|
||||
<h3>{{ title }}</h3>
|
||||
<hr>
|
||||
|
||||
<div id='button-toolbar'>
|
||||
<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>
|
||||
|
||||
@ -35,6 +35,9 @@ InvenTree | {% trans "Supplier List" %}
|
||||
|
||||
loadCompanyTable("#company-table", "{% url 'api-company-list' %}",
|
||||
{
|
||||
params: {
|
||||
{% for key,value in filters.items %}{{ key }}: "{{ value }}",{% endfor %}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -33,10 +33,12 @@ company_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
|
||||
url(r'^.*$', RedirectView.as_view(url='', permanent=False), name='company-index'),
|
||||
url(r'^.*$', views.CompanyIndex.as_view(), name='company-index'),
|
||||
]
|
||||
|
||||
price_break_urls = [
|
||||
|
@ -39,6 +39,37 @@ class CompanyIndex(ListView):
|
||||
context_object_name = 'companies'
|
||||
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):
|
||||
""" Retrieve the Company queryset based on HTTP request parameters.
|
||||
|
||||
|
@ -13,11 +13,17 @@
|
||||
<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>
|
||||
<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 'company-index' %}"><span class='fas fa-industry icon-header'></span>{% trans "Manufacturers" %}</a></li>
|
||||
<li><a href="{% url 'supplier-index' %}"><span class='fas fa-building icon-header'></span>{% trans "Suppliers" %}</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>
|
||||
</ul>
|
||||
</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 class="nav navbar-nav navbar-right">
|
||||
{% include "search_form.html" %}
|
||||
|
Loading…
Reference in New Issue
Block a user