Merge remote-tracking branch 'inventree/master'

This commit is contained in:
Oliver Walters 2020-10-20 21:22:55 +11:00
commit 178a260bde
3 changed files with 19 additions and 11 deletions

View File

@ -181,8 +181,15 @@ function customGroupSorter(sortName, sortOrder, sortData) {
sortData.sort(function(a, b) {
// Extract default field values
var aa = a[sortName];
var bb = b[sortName];
// Allow multi-level access if required
// Ref: https://stackoverflow.com/a/6394168
function extract(obj, i) {
return obj[i];
}
var aa = sortName.split('.').reduce(extract, a);
var bb = sortName.split('.').reduce(extract, b);
// Extract parent information
var aparent = a._data && a._data['parent-index'];

View File

@ -1,5 +1,5 @@
from django.apps import AppConfig
from django.db.utils import OperationalError, ProgrammingError
from django.db.utils import OperationalError, ProgrammingError, IntegrityError
class CommonConfig(AppConfig):
@ -48,7 +48,7 @@ class CommonConfig(AppConfig):
value=instance_name
)
except (OperationalError, ProgrammingError):
except (OperationalError, ProgrammingError, IntegrityError):
# Migrations have not yet been applied - table does not exist
pass
@ -87,6 +87,6 @@ class CommonConfig(AppConfig):
setting.key = key
setting.save()
except (OperationalError, ProgrammingError):
except (OperationalError, ProgrammingError, IntegrityError):
# Table might not yet exist
pass

View File

@ -274,16 +274,16 @@ function loadStockTable(table, options) {
var row = data[0];
if (field == 'part_name') {
if (field == 'part_detail.name') {
var name = row.part_detail.full_name;
return imageHoverIcon(row.part_detail.thumbnail) + name + ' <i>(' + data.length + ' items)</i>';
}
else if (field == 'IPN') {
else if (field == 'part_detail.IPN') {
return row.part_detail.IPN;
}
else if (field == 'part_description') {
else if (field == 'part_detail.description') {
return row.part_detail.description;
}
else if (field == 'quantity') {
@ -417,9 +417,10 @@ function loadStockTable(table, options) {
switchable: false,
},
{
field: 'part_name',
field: 'part_detail.name',
title: '{% trans "Part" %}',
sortable: true,
switchable: false,
formatter: function(value, row, index, field) {
var url = `/stock/item/${row.pk}/`;
@ -432,7 +433,7 @@ function loadStockTable(table, options) {
}
},
{
field: 'IPN',
field: 'part_detail.IPN',
title: 'IPN',
sortable: true,
formatter: function(value, row, index, field) {
@ -440,7 +441,7 @@ function loadStockTable(table, options) {
},
},
{
field: 'part_description',
field: 'part_detail.description',
title: '{% trans "Description" %}',
sortable: true,
formatter: function(value, row, index, field) {