Improve server-side pagination for POLineItem

This commit is contained in:
Oliver Walters 2021-03-02 12:38:37 +11:00
parent 1c3b017283
commit 6f4178acdb
2 changed files with 26 additions and 2 deletions

View File

@ -200,6 +200,22 @@ class POLineItemList(generics.ListCreateAPIView):
filter_backends = [
DjangoFilterBackend,
filters.SearchFilter,
filters.OrderingFilter
]
ordering_fields = [
'part__part__name',
'part__MPN',
'part__SKU',
'reference',
'quantity',
'received',
]
search_Fields = [
'part__part__name',
'part__part__description',
]
filter_fields = [

View File

@ -135,6 +135,7 @@ function setupCallbacks() {
$("#po-table").inventreeTable({
onPostBody: setupCallbacks,
name: 'purchaseorder',
sidePagination: 'server',
formatNoMatches: function() { return "{% trans 'No line items found' %}"; },
queryParams: {
order: {{ order.id }},
@ -151,6 +152,7 @@ $("#po-table").inventreeTable({
{
field: 'part',
sortable: true,
sortName: 'part__part__name',
title: '{% trans "Part" %}',
switchable: false,
formatter: function(value, row, index, field) {
@ -162,18 +164,24 @@ $("#po-table").inventreeTable({
},
},
{
sortable: true,
field: 'part_detail.description',
title: '{% trans "Description" %}',
},
{
sortable: true,
sortName: 'part__SKU',
field: 'supplier_part_detail.SKU',
title: '{% trans "Order Code" %}',
title: '{% trans "SKU" %}',
formatter: function(value, row, index, field) {
return renderLink(value, `/supplier-part/${row.part}/`);
},
},
{
sortable: true,
sortName: 'part__MPN',
field: 'supplier_part_detail.MPN',
title: '{% trans "MPN" %}',
},
{
sortable: true,
field: 'reference',