From 4f432d4db2b8ce4d63019fa650dd327eaaa995f9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 3 Jul 2021 01:47:54 +0200 Subject: [PATCH 1/4] extend api with issuer #1356 --- InvenTree/build/api.py | 2 ++ InvenTree/build/serializers.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/InvenTree/build/api.py b/InvenTree/build/api.py index 1cb973fe05..50b0d2da72 100644 --- a/InvenTree/build/api.py +++ b/InvenTree/build/api.py @@ -46,6 +46,8 @@ class BuildList(generics.ListCreateAPIView): 'target_date', 'completion_date', 'quantity', + 'issued_by', + 'responsible', ] search_fields = [ diff --git a/InvenTree/build/serializers.py b/InvenTree/build/serializers.py index d8573cfa70..72295ecab1 100644 --- a/InvenTree/build/serializers.py +++ b/InvenTree/build/serializers.py @@ -10,7 +10,7 @@ from django.db.models import BooleanField from rest_framework import serializers -from InvenTree.serializers import InvenTreeModelSerializer +from InvenTree.serializers import InvenTreeModelSerializer, UserSerializerBrief from stock.serializers import StockItemSerializerBrief from stock.serializers import LocationSerializer @@ -31,6 +31,8 @@ class BuildSerializer(InvenTreeModelSerializer): overdue = serializers.BooleanField(required=False, read_only=True) + issued_by_detail = UserSerializerBrief(source='issued_by', read_only=True) + @staticmethod def annotate_queryset(queryset): """ @@ -84,6 +86,9 @@ class BuildSerializer(InvenTreeModelSerializer): 'target_date', 'notes', 'link', + 'issued_by', + 'issued_by_detail', + 'responsible', ] read_only_fields = [ From ffa9dd18cf01384b4b1e28711033018d3af70e08 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 3 Jul 2021 01:49:18 +0200 Subject: [PATCH 2/4] adding new fields into table --- InvenTree/templates/js/build.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/InvenTree/templates/js/build.js b/InvenTree/templates/js/build.js index 7b72149ec9..088c005dce 100644 --- a/InvenTree/templates/js/build.js +++ b/InvenTree/templates/js/build.js @@ -876,6 +876,26 @@ function loadBuildTable(table, options) { title: '{% trans "Created" %}', sortable: true, }, + { + field: 'issued_by', + title: '{% trans "Issued by" %}', + sortable: true, + formatter: function(value, row, index, field) { + if (value) + { + return row.issued_by_detail.username; + } + else + { + return '{% trans "No user information" %}'; + } + } + }, + { + field: 'responsible', + title: '{% trans "Resposible" %}', + sortable: true, + }, { field: 'target_date', title: '{% trans "Target Date" %}', From 7b3bc33b8872eade55596a8ebed0eef055189e50 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 4 Jul 2021 00:15:44 +0200 Subject: [PATCH 3/4] using owner serializer --- InvenTree/build/serializers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/InvenTree/build/serializers.py b/InvenTree/build/serializers.py index 8e343831d5..363614035a 100644 --- a/InvenTree/build/serializers.py +++ b/InvenTree/build/serializers.py @@ -15,6 +15,7 @@ from InvenTree.serializers import InvenTreeModelSerializer, InvenTreeAttachmentS from stock.serializers import StockItemSerializerBrief from stock.serializers import LocationSerializer from part.serializers import PartSerializer, PartBriefSerializer +from users.serializers import OwnerSerializer from .models import Build, BuildItem, BuildOrderAttachment @@ -33,6 +34,8 @@ class BuildSerializer(InvenTreeModelSerializer): issued_by_detail = UserSerializerBrief(source='issued_by', read_only=True) + responsible_detail = OwnerSerializer(source='responsible', read_only=True) + @staticmethod def annotate_queryset(queryset): """ @@ -89,6 +92,7 @@ class BuildSerializer(InvenTreeModelSerializer): 'issued_by', 'issued_by_detail', 'responsible', + 'responsible_detail', ] read_only_fields = [ From 4711f0b823a8acdaf276a9368119a7c4cc679b55 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 4 Jul 2021 00:16:14 +0200 Subject: [PATCH 4/4] fromatter for responsible group --- InvenTree/templates/js/build.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/InvenTree/templates/js/build.js b/InvenTree/templates/js/build.js index 088c005dce..67961d1b73 100644 --- a/InvenTree/templates/js/build.js +++ b/InvenTree/templates/js/build.js @@ -895,6 +895,16 @@ function loadBuildTable(table, options) { field: 'responsible', title: '{% trans "Resposible" %}', sortable: true, + formatter: function(value, row, index, field) { + if (value) + { + return row.responsible_detail.name; + } + else + { + return '{% trans "No information" %}'; + } + } }, { field: 'target_date',