mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-27 22:26:00 +00:00
[UI] PO Receive bug (#12709)
* [UI] Fix for receiving items * Add playwright regression test
This commit is contained in:
@@ -375,13 +375,12 @@ function LineItemFormRow({
|
||||
}, [record.destination]);
|
||||
|
||||
// Batch code generator
|
||||
// Note: the generated value is offered as a placeholder (accepted via the
|
||||
// "accept suggested value" button) rather than written into the field
|
||||
// directly - otherwise, a manually-entered batch code can be silently
|
||||
// overwritten if the (debounced, async) generator resolves afterwards
|
||||
const batchCodeGenerator = useBatchCodeGenerator({
|
||||
isEnabled: () => batchOpen,
|
||||
onGenerate: (value: any) => {
|
||||
if (value) {
|
||||
props.changeFn(props.rowId, 'batch_code', value);
|
||||
}
|
||||
}
|
||||
isEnabled: () => batchOpen
|
||||
});
|
||||
|
||||
// Serial number generator
|
||||
@@ -776,7 +775,10 @@ function LineItemFormRow({
|
||||
field_type: 'string',
|
||||
label: t`Batch Code`,
|
||||
description: t`Enter batch code for received items`,
|
||||
value: props.item.batch_code
|
||||
value: props.item.batch_code,
|
||||
placeholderAutofill: true,
|
||||
placeholder:
|
||||
batchCodeGenerator.result && `${batchCodeGenerator.result}`
|
||||
}}
|
||||
error={props.rowErrors?.batch_code?.message}
|
||||
/>
|
||||
@@ -898,7 +900,13 @@ export function useReceiveLineItems(props: LineItemsForm) {
|
||||
return {
|
||||
id: elem.pk,
|
||||
line_item: elem.pk,
|
||||
location: elem.destination ?? elem.destination_detail?.pk ?? null,
|
||||
// Leave unset if this line has no destination of its own, so a
|
||||
// manually-selected location (or the order's own destination
|
||||
// fallback) is actually applied — `destination_detail` already
|
||||
// resolves through that fallback chain, so baking its value in
|
||||
// here would make the backend treat this line as if the user
|
||||
// had explicitly chosen the PO's default, blocking any override.
|
||||
location: elem.destination ?? null,
|
||||
quantity: elem.quantity - elem.received,
|
||||
expiry_date: null,
|
||||
batch_code: '',
|
||||
@@ -938,7 +946,7 @@ export function useReceiveLineItems(props: LineItemsForm) {
|
||||
}
|
||||
}
|
||||
};
|
||||
}, [filteredItems, records, props, stockStatusCodes]);
|
||||
}, [filteredItems, records, props.orderPk, stockStatusCodes]);
|
||||
|
||||
return useCreateApiFormModal({
|
||||
...props.formProps,
|
||||
|
||||
Reference in New Issue
Block a user