2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

Fix for stock item form (#9892)

This commit is contained in:
Oliver
2025-06-28 12:09:19 +10:00
committed by GitHub
parent 4b70a6e4ca
commit 5ccf7a6e45
2 changed files with 15 additions and 5 deletions

View File

@ -85,21 +85,21 @@ export function useStockFields({
const batchGenerator = useBatchCodeGenerator({ const batchGenerator = useBatchCodeGenerator({
modalId: modalId, modalId: modalId,
initialQuery: { initialQuery: {
part: partInstance?.pk || partId part: partId
} }
}); });
const serialGenerator = useSerialNumberGenerator({ const serialGenerator = useSerialNumberGenerator({
modalId: modalId, modalId: modalId,
initialQuery: { initialQuery: {
part: partInstance?.pk || partId part: partId
} }
}); });
return useMemo(() => { return useMemo(() => {
const fields: ApiFormFieldSet = { const fields: ApiFormFieldSet = {
part: { part: {
value: partInstance.pk, value: partId || partInstance?.pk,
disabled: !create, disabled: !create,
filters: { filters: {
active: create ? true : undefined active: create ? true : undefined
@ -108,6 +108,14 @@ export function useStockFields({
// Update the tracked part instance // Update the tracked part instance
setPartInstance(record); setPartInstance(record);
serialGenerator.update({
part: value
});
batchGenerator.update({
part: value
});
// Clear the 'supplier_part' field if the part is changed // Clear the 'supplier_part' field if the part is changed
setSupplierPart(null); setSupplierPart(null);

View File

@ -87,8 +87,8 @@ export function useGenerator(props: GeneratorProps): GeneratorState {
refetchOnWindowFocus: false, refetchOnWindowFocus: false,
queryFn: async () => { queryFn: async () => {
const generatorQuery = { const generatorQuery = {
...debouncedQuery, ...(props.initialQuery ?? {}),
...(props.initialQuery ?? {}) ...debouncedQuery
}; };
if (!isEnabled()) { if (!isEnabled()) {
@ -111,6 +111,8 @@ export function useGenerator(props: GeneratorProps): GeneratorState {
`Error generating ${props.key} @ ${props.endpoint}:`, `Error generating ${props.key} @ ${props.endpoint}:`,
error error
); );
return null;
}); });
} }
}); });