mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fixes for ordering of stock table
This commit is contained in:
parent
212a7eeed1
commit
bad246bca6
@ -383,7 +383,7 @@ $("#po-table").inventreeTable({
|
||||
}
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
sortable: false,
|
||||
field: 'received',
|
||||
switchable: false,
|
||||
title: '{% trans "Received" %}',
|
||||
|
@ -43,6 +43,7 @@ from .serializers import StockItemTestResultSerializer
|
||||
from InvenTree.views import TreeSerializer
|
||||
from InvenTree.helpers import str2bool, isNull
|
||||
from InvenTree.api import AttachmentMixin
|
||||
from InvenTree.filters import InvenTreeOrderingFilter
|
||||
|
||||
from decimal import Decimal, InvalidOperation
|
||||
|
||||
@ -882,10 +883,16 @@ class StockList(generics.ListCreateAPIView):
|
||||
filter_backends = [
|
||||
DjangoFilterBackend,
|
||||
filters.SearchFilter,
|
||||
filters.OrderingFilter,
|
||||
InvenTreeOrderingFilter,
|
||||
]
|
||||
|
||||
ordering_field_aliases = {
|
||||
'SKU': 'supplier_part__SKU',
|
||||
}
|
||||
|
||||
ordering_fields = [
|
||||
'batch',
|
||||
'location',
|
||||
'part__name',
|
||||
'part__IPN',
|
||||
'updated',
|
||||
@ -893,10 +900,13 @@ class StockList(generics.ListCreateAPIView):
|
||||
'expiry_date',
|
||||
'quantity',
|
||||
'status',
|
||||
'SKU',
|
||||
]
|
||||
|
||||
ordering = [
|
||||
'part__name'
|
||||
'part__name',
|
||||
'quantity',
|
||||
'location',
|
||||
]
|
||||
|
||||
search_fields = [
|
||||
|
@ -921,8 +921,10 @@ function loadStockTable(table, options) {
|
||||
|
||||
return renderLink(text, link);
|
||||
}
|
||||
},
|
||||
{
|
||||
});
|
||||
|
||||
col = {
|
||||
|
||||
field: 'supplier_part',
|
||||
title: '{% trans "Supplier Part" %}',
|
||||
visible: params['supplier_part_detail'] || false,
|
||||
@ -944,15 +946,25 @@ function loadStockTable(table, options) {
|
||||
|
||||
return renderLink(text, link);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (!options.params.ordering) {
|
||||
col.sortable = true;
|
||||
col.sortName = 'SKU';
|
||||
}
|
||||
|
||||
columns.push(col);
|
||||
|
||||
col = {
|
||||
field: 'purchase_price_string',
|
||||
title: '{% trans "Purchase Price" %}',
|
||||
};
|
||||
|
||||
if (!options.params.ordering) {
|
||||
col['sortable'] = true;
|
||||
col.sortable = true;
|
||||
col.sortName = 'purchase_price';
|
||||
};
|
||||
|
||||
columns.push(col);
|
||||
|
||||
columns.push({
|
||||
|
Loading…
Reference in New Issue
Block a user