2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-30 20:46:47 +00:00

Fix rendering of supplier pack quantity (#6228)

Backport of https://github.com/inventree/InvenTree/pull/6226
This commit is contained in:
Oliver 2024-01-13 20:01:19 +11:00 committed by GitHub
parent e22779872e
commit 4973d9c726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -337,6 +337,7 @@ class SupplierPartSerializer(InvenTreeTagModelSerializer):
read_only_fields = [
'availability_updated',
'barcode_hash',
'pack_quantity_native',
]
tags = TagListSerializerField(required=False)
@ -375,6 +376,8 @@ class SupplierPartSerializer(InvenTreeTagModelSerializer):
in_stock = serializers.FloatField(read_only=True)
available = serializers.FloatField(required=False)
pack_quantity_native = serializers.FloatField(read_only=True)
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
supplier_detail = CompanyBriefSerializer(source='supplier', many=False, read_only=True)

View File

@ -1812,12 +1812,13 @@ function loadPartPurchaseOrderTable(table, part_id, options={}) {
formatter: function(value, row) {
let data = value;
if (row.supplier_part_detail.pack_quantity_native != 1.0) {
let total = value * row.supplier_part_detail.pack_quantity_native;
if (row.supplier_part_detail && row.supplier_part_detail.pack_quantity_native != 1.0) {
let pq = row.supplier_part_detail.pack_quantity_native;
let total = value * pq;
data += makeIconBadge(
'fa-info-circle icon-blue',
`{% trans "Pack Quantity" %}: ${row.pack_quantity} - {% trans "Total Quantity" %}: ${total}`
`{% trans "Pack Quantity" %}: ${pq} - {% trans "Total Quantity" %}: ${total}`
);
}
@ -1870,9 +1871,10 @@ function loadPartPurchaseOrderTable(table, part_id, options={}) {
formatter: function(value, row) {
var data = value;
if (value > 0 && row.supplier_part_detail.pack_quantity_native != 1.0) {
let total = value * row.supplier_part_detail.pack_quantity_native;
data += `<span class='fas fa-info-circle icon-blue float-right' title='{% trans "Pack Quantity" %}: ${row.pack_quantity} - {% trans "Total Quantity" %}: ${total}'></span>`;
if (value > 0 && row.supplier_part_detail && row.supplier_part_detail.pack_quantity_native != 1.0) {
let pq = row.supplier_part_detail.pack_quantity_native;
let total = value * pq;
data += `<span class='fas fa-info-circle icon-blue float-right' title='{% trans "Pack Quantity" %}: ${pq} - {% trans "Total Quantity" %}: ${total}'></span>`;
}
return data;