From 70b88dbb1cb052711b7ba7ad96af26f5822b2a33 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 3 May 2024 15:22:40 +1000 Subject: [PATCH] Stock transfer dialog fix (#7150) * Bug fix for stock adjustment dialog - Comparing to null is not sufficient * Update PUI form too * Fix logic * Bug fix --- .../templates/js/translated/stock.js | 19 +++++++++++-------- src/frontend/src/forms/StockForms.tsx | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/backend/InvenTree/templates/js/translated/stock.js b/src/backend/InvenTree/templates/js/translated/stock.js index 5254eec00f..e88f0602bb 100644 --- a/src/backend/InvenTree/templates/js/translated/stock.js +++ b/src/backend/InvenTree/templates/js/translated/stock.js @@ -1110,11 +1110,8 @@ function adjustStock(action, items, options={}) { classes: 'float-right' }); - var quantity = item.quantity; + let quantityString = ''; - if (item.part_detail.units != null) { - quantity += ` ${item.part_detail.units}`; - } var location = locationDetail(item, false); @@ -1122,12 +1119,18 @@ function adjustStock(action, items, options={}) { location = item.location_detail.pathstring; } - if (item.serial != null) { - quantity = `#${item.serial}`; + if (!item.serial) { + quantityString = `${item.quantity}`; + + if (item.part_detail?.units) { + quantityString += ` [${item.part_detail.units}]`; + } + } else { + quantityString = `#${item.serial}`; } if (item.batch) { - quantity += ` - {% trans "Batch" %}: ${item.batch}`; + quantityString += ` - {% trans "Batch" %}: ${item.batch}`; } var actionInput = ''; @@ -1158,7 +1161,7 @@ function adjustStock(action, items, options={}) { html += ` ${thumb} ${item.part_detail.full_name} - ${quantity}${status} + ${quantityString}${status} ${location}
diff --git a/src/frontend/src/forms/StockForms.tsx b/src/frontend/src/forms/StockForms.tsx index b408f1ece4..fe65710051 100644 --- a/src/frontend/src/forms/StockForms.tsx +++ b/src/frontend/src/forms/StockForms.tsx @@ -1,5 +1,5 @@ import { t } from '@lingui/macro'; -import { Flex, NumberInput, Skeleton, Text } from '@mantine/core'; +import { Flex, Group, NumberInput, Skeleton, Text } from '@mantine/core'; import { modals } from '@mantine/modals'; import { useQuery, useSuspenseQuery } from '@tanstack/react-query'; import { Suspense, useCallback, useMemo, useState } from 'react'; @@ -283,6 +283,14 @@ function StockOperationsRow({ input.removeFn(input.idx); }; + const stockString: string = useMemo(() => { + if (!record.serial) { + return `${record.quantity}`; + } else { + return `#${record.serial}`; + } + }, record); + return ( @@ -298,8 +306,10 @@ function StockOperationsRow({ {record.location ? record.location_detail.pathstring : '-'} - {record.quantity} - + + {stockString} + + {!merge && (