mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 04:55:44 +00:00
Separate views for customer / supplier / manufacturer
This commit is contained in:
@ -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.
|
||||
|
||||
|
Reference in New Issue
Block a user