mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Display packaging info in stock table
This commit is contained in:
		@@ -198,6 +198,7 @@ class StockItemSerializer(InvenTreeModelSerializer):
 | 
				
			|||||||
            'location',
 | 
					            'location',
 | 
				
			||||||
            'location_detail',
 | 
					            'location_detail',
 | 
				
			||||||
            'notes',
 | 
					            'notes',
 | 
				
			||||||
 | 
					            'packaging',
 | 
				
			||||||
            'part',
 | 
					            'part',
 | 
				
			||||||
            'part_detail',
 | 
					            'part_detail',
 | 
				
			||||||
            'pk',
 | 
					            'pk',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -359,6 +359,29 @@ function loadStockTable(table, options) {
 | 
				
			|||||||
            else if (field == 'part_detail.description') {
 | 
					            else if (field == 'part_detail.description') {
 | 
				
			||||||
                return row.part_detail.description;
 | 
					                return row.part_detail.description;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            else if (field == 'packaging') {
 | 
				
			||||||
 | 
					                var packaging = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                data.forEach(function(item) {
 | 
				
			||||||
 | 
					                    var pkg = String(item.packaging);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (!pkg || pkg == '') {
 | 
				
			||||||
 | 
					                        pkg = '-';
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (!packaging.includes(pkg)) {
 | 
				
			||||||
 | 
					                        packaging.push(pkg);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (packaging.length > 1) {
 | 
				
			||||||
 | 
					                    return "...";
 | 
				
			||||||
 | 
					                } else if (packaging.length == 1) {
 | 
				
			||||||
 | 
					                    return packaging[0];
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    return "-";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            else if (field == 'quantity') {
 | 
					            else if (field == 'quantity') {
 | 
				
			||||||
                var stock = 0;
 | 
					                var stock = 0;
 | 
				
			||||||
                var items = 0;
 | 
					                var items = 0;
 | 
				
			||||||
@@ -388,7 +411,7 @@ function loadStockTable(table, options) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                // Multiple status codes
 | 
					                // Multiple status codes
 | 
				
			||||||
                if (statii.length > 1) {
 | 
					                if (statii.length > 1) {
 | 
				
			||||||
                    return "-";
 | 
					                    return "...";
 | 
				
			||||||
                } else if (statii.length == 1) {
 | 
					                } else if (statii.length == 1) {
 | 
				
			||||||
                    return stockStatusDisplay(statii[0]);
 | 
					                    return stockStatusDisplay(statii[0]);
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
@@ -619,6 +642,12 @@ function loadStockTable(table, options) {
 | 
				
			|||||||
                title: '{% trans "Last Updated" %}',
 | 
					                title: '{% trans "Last Updated" %}',
 | 
				
			||||||
                sortable: true,
 | 
					                sortable: true,
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                field: 'packaging',
 | 
				
			||||||
 | 
					                title: '{% trans "Packaging" %}',
 | 
				
			||||||
 | 
					                sortable: true,
 | 
				
			||||||
 | 
					                searchable: true,
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                field: 'notes',
 | 
					                field: 'notes',
 | 
				
			||||||
                title: '{% trans "Notes" %}',
 | 
					                title: '{% trans "Notes" %}',
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user