2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-18 10:46:31 +00:00

Stock serialize tweaks (#10017)

* Better item extraction

* Improve query efficiency

* Further queryset improvements

* Return correct data format

* Test with hugh number of serials

* Improve serialization UX

* Revert changes to unit tests
This commit is contained in:
Oliver
2025-07-15 00:00:38 +10:00
committed by GitHub
parent 22218fd5c6
commit 9f715337ec
6 changed files with 50 additions and 15 deletions

View File

@@ -66,6 +66,15 @@ export function useInstance<T = any>({
JSON.stringify(pathParams),
disabled
],
retry: (failureCount, error: any) => {
// If it's a 404, don't retry
if (error.response?.status == 404) {
return false;
}
// Otherwise, retry up to 3 times
return failureCount < 3;
},
queryFn: async () => {
if (disabled) {
return defaultValue;

View File

@@ -744,12 +744,14 @@ export default function StockDetail() {
quantity: stockitem.quantity,
destination: stockitem.location ?? stockitem.part_detail?.default_location
},
onFormSuccess: () => {
const partId = stockitem.part;
refreshInstancePromise().catch(() => {
// Part may have been deleted - redirect to the part detail page
navigate(getDetailUrl(ModelType.part, partId));
});
onFormSuccess: (response: any) => {
if (response.length >= stockitem.quantity) {
// Entire item was serialized
// Navigate to the first result
navigate(getDetailUrl(ModelType.stockitem, response[0].pk));
} else {
refreshInstance();
}
},
successMessage: t`Stock item serialized`
});