Fix rendering of supplier part pack quantity (#6226)

- Fixes https://github.com/inventree/InvenTree/issues/6224
This commit is contained in:
Oliver 2024-01-13 08:06:47 +11:00 committed by GitHub
parent 213a63318d
commit 9b1a310ffe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View File

@ -326,7 +326,11 @@ class SupplierPartSerializer(InvenTreeTagModelSerializer):
'tags',
]
read_only_fields = ['availability_updated', 'barcode_hash']
read_only_fields = [
'availability_updated',
'barcode_hash',
'pack_quantity_native',
]
tags = TagListSerializerField(required=False)
@ -364,6 +368,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(

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;