Renderer for supplier part

This commit is contained in:
Oliver 2021-07-02 17:11:07 +10:00
parent 52952a8a8b
commit 72526307ae
4 changed files with 30 additions and 5 deletions

View File

@ -179,9 +179,10 @@ class SupplierPartSerializer(InvenTreeModelSerializer):
def __init__(self, *args, **kwargs):
part_detail = kwargs.pop('part_detail', False)
supplier_detail = kwargs.pop('supplier_detail', False)
manufacturer_detail = kwargs.pop('manufacturer_detail', False)
part_detail = kwargs.pop('part_detail', True)
supplier_detail = kwargs.pop('supplier_detail', True)
manufacturer_detail = kwargs.pop('manufacturer_detail', True)
prettify = kwargs.pop('pretty', False)
super(SupplierPartSerializer, self).__init__(*args, **kwargs)

View File

@ -336,9 +336,10 @@ class PartSerializer(InvenTreeModelSerializer):
'category',
'category_detail',
'component',
'description',
'default_location',
'default_expiry',
'default_location',
'default_supplier',
'description',
'full_name',
'image',
'in_stock',

View File

@ -1128,6 +1128,9 @@ function renderModelData(name, model, data, parameters, options) {
case 'partcategory':
renderer = renderPartCategory;
break;
case 'supplierpart':
renderer = renderSupplierPart;
break;
default:
break;
}

View File

@ -109,4 +109,24 @@ function renderPartCategory(name, data, parameters, options) {
}
return html;
}
// Rendered for "SupplierPart" model
function renderSupplierPart(name, data, parameters, options) {
var image = data.supplier_detail.image;
if (!image) {
image = `/static/img/blank_image.png`;
}
var html = `<img src='${image}' class='select2-thumbnail'>`;
html += ` <span><b>${data.supplier_detail.name}</b> - ${data.SKU}</span>`;
html += `<span class='float-right'>{% trans "Supplier Part ID" %}: ${data.pk}</span>`;
return html;
}