From b77b6d22561556aa00eeb6b06d70fcc9725e6ba5 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 16 May 2019 22:29:39 +1000 Subject: [PATCH] Display number of supplier parts in supplier list --- InvenTree/company/serializers.py | 20 ++++++++++++++++++- .../company/templates/company/index.html | 9 ++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/InvenTree/company/serializers.py b/InvenTree/company/serializers.py index 88792f7f64..2967dbebd5 100644 --- a/InvenTree/company/serializers.py +++ b/InvenTree/company/serializers.py @@ -25,7 +25,25 @@ class CompanySerializer(serializers.ModelSerializer): """ Serializer for Company object (full detail) """ url = serializers.CharField(source='get_absolute_url', read_only=True) + part_count = serializers.CharField(read_only=True) class Meta: model = Company - fields = '__all__' + fields = [ + 'id', + 'url', + 'name', + 'description', + 'website', + 'name', + 'phone', + 'address', + 'email', + 'contact', + 'URL', + 'image', + 'notes', + 'is_customer', + 'is_supplier', + 'part_count' + ] diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index d4a8659798..cea452fdc1 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -73,7 +73,14 @@ InvenTree | Supplier List } return ''; } - } + }, + { + field: 'part_count', + title: 'Parts', + formatter: function(value, row, index, field) { + return renderLink(value, row.url + 'parts/'); + } + }, ], url: "{% url 'api-company-list' %}" });