From f427ee4754368da9ce3d23a3fa33747c84e9c858 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 13 Apr 2020 12:16:42 +1000 Subject: [PATCH] Improvements to company API - Filter by is_manufacturer - Better table display --- InvenTree/company/api.py | 3 ++- .../migrations/0016_auto_20200412_2330.py | 18 ++++++++++++++++++ InvenTree/company/models.py | 2 +- InvenTree/company/serializers.py | 3 ++- InvenTree/company/templates/company/index.html | 16 +++++++++++++++- InvenTree/company/urls.py | 2 +- InvenTree/templates/navbar.html | 10 ++++++++-- 7 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 InvenTree/company/migrations/0016_auto_20200412_2330.py diff --git a/InvenTree/company/api.py b/InvenTree/company/api.py index 8b777dd947..4231dc8434 100644 --- a/InvenTree/company/api.py +++ b/InvenTree/company/api.py @@ -43,9 +43,10 @@ class CompanyList(generics.ListCreateAPIView): ] filter_fields = [ - 'name', 'is_customer', + 'is_manufacturer', 'is_supplier', + 'name', ] search_fields = [ diff --git a/InvenTree/company/migrations/0016_auto_20200412_2330.py b/InvenTree/company/migrations/0016_auto_20200412_2330.py new file mode 100644 index 0000000000..cec6f5a219 --- /dev/null +++ b/InvenTree/company/migrations/0016_auto_20200412_2330.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.10 on 2020-04-12 23:30 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('company', '0015_company_is_manufacturer'), + ] + + operations = [ + migrations.AlterField( + model_name='company', + name='is_manufacturer', + field=models.BooleanField(default=False, help_text='Does this company manufacture parts?'), + ), + ] diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index f1610e5687..f99c855c77 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -112,7 +112,7 @@ class Company(models.Model): is_supplier = models.BooleanField(default=True, help_text=_('Do you purchase items from this company?')) - is_manufacturer = models.BooleanField(default=True, help_text=_('Does this company manufacture parts?')) + is_manufacturer = models.BooleanField(default=False, help_text=_('Does this company manufacture parts?')) def __str__(self): """ Get string representation of a Company """ diff --git a/InvenTree/company/serializers.py b/InvenTree/company/serializers.py index 935712a180..218201179e 100644 --- a/InvenTree/company/serializers.py +++ b/InvenTree/company/serializers.py @@ -49,9 +49,10 @@ class CompanySerializer(InvenTreeModelSerializer): 'contact', 'link', 'image', - 'notes', 'is_customer', + 'is_manufacturer', 'is_supplier', + 'notes', 'part_count' ] diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index 0c5e3a6931..2bdc936db8 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -46,7 +46,21 @@ InvenTree | {% trans "Supplier List" %} title: '{% trans "Supplier" %}', sortable: true, formatter: function(value, row, index, field) { - return imageHoverIcon(row.image) + renderLink(value, row.url); + var html = imageHoverIcon(row.image) + renderLink(value, row.url); + + if (row.is_customer) { + html += ``; + } + + if (row.is_manufacturer) { + html += ``; + } + + if (row.is_supplier) { + html += ``; + } + + return html; } }, { diff --git a/InvenTree/company/urls.py b/InvenTree/company/urls.py index 65eba73f84..c00d1e7a4b 100644 --- a/InvenTree/company/urls.py +++ b/InvenTree/company/urls.py @@ -35,7 +35,7 @@ company_urls = [ url(r'', views.CompanyIndex.as_view(), name='company-index'), - # Redirect any other patterns + # Redirect any other patterns to the 'company' index which displays all companies url(r'^.*$', RedirectView.as_view(url='', permanent=False), name='company-index'), ] diff --git a/InvenTree/templates/navbar.html b/InvenTree/templates/navbar.html index e44107e2d1..202fb2a0ce 100644 --- a/InvenTree/templates/navbar.html +++ b/InvenTree/templates/navbar.html @@ -10,8 +10,14 @@
  • {% trans "Parts" %}
  • {% trans "Stock" %}
  • {% trans "Build" %}
  • -
  • {% trans "Suppliers" %}
  • -
  • {% trans "Orders" %}
  • +