Merge pull request #1749 from matmair/extend-build-order

Extend build order table
This commit is contained in:
Oliver 2021-07-06 11:23:36 +10:00 committed by GitHub
commit c2df1fcd95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 1 deletions

View File

@ -47,6 +47,8 @@ class BuildList(generics.ListCreateAPIView):
'target_date',
'completion_date',
'quantity',
'issued_by',
'responsible',
]
search_fields = [

View File

@ -10,11 +10,12 @@ from django.db.models import BooleanField
from rest_framework import serializers
from InvenTree.serializers import InvenTreeModelSerializer, InvenTreeAttachmentSerializerField
from InvenTree.serializers import InvenTreeModelSerializer, InvenTreeAttachmentSerializerField, UserSerializerBrief
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
@ -31,6 +32,10 @@ class BuildSerializer(InvenTreeModelSerializer):
overdue = serializers.BooleanField(required=False, read_only=True)
issued_by_detail = UserSerializerBrief(source='issued_by', read_only=True)
responsible_detail = OwnerSerializer(source='responsible', read_only=True)
@staticmethod
def annotate_queryset(queryset):
"""
@ -84,6 +89,10 @@ class BuildSerializer(InvenTreeModelSerializer):
'target_date',
'notes',
'link',
'issued_by',
'issued_by_detail',
'responsible',
'responsible_detail',
]
read_only_fields = [

View File

@ -876,6 +876,36 @@ 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,
formatter: function(value, row, index, field) {
if (value)
{
return row.responsible_detail.name;
}
else
{
return '{% trans "No information" %}';
}
}
},
{
field: 'target_date',
title: '{% trans "Target Date" %}',