2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-06-06 08:54:24 +00:00

Fix for "can convert" logic (#12070)

- Fetch full part detail
This commit is contained in:
Oliver
2026-06-02 16:43:08 +10:00
committed by GitHub
parent 0f717e2749
commit 75e3f522d4
+10 -4
View File
@@ -122,6 +122,13 @@ export default function StockDetail() {
}
});
const { instance: part, instanceQuery: partQuery } = useInstance({
endpoint: ApiEndpoints.part_list,
pk: stockitem?.part,
hasPrimaryKey: true,
defaultValue: {}
});
const { instance: serialNumbers, instanceQuery: serialNumbersQuery } =
useInstance({
endpoint: ApiEndpoints.stock_serial_info,
@@ -884,9 +891,8 @@ export default function StockDetail() {
serial != '' &&
stockitem.quantity == 1;
const canConvert =
!!stockitem.part_detail?.variant_of ||
!!stockitem.part_detail?.is_template;
// Allow variant conversion if the part is a variant, or if the part is a template
const canConvert = part?.variant_of || part?.is_template;
return [
<AdminButton model={ModelType.stockitem} id={stockitem.pk} />,
@@ -967,7 +973,7 @@ export default function StockDetail() {
]}
/>
];
}, [id, stockitem, user, stockAdjustActions.menuActions]);
}, [id, stockitem, part, user, stockAdjustActions.menuActions]);
const stockBadges: ReactNode[] = useMemo(() => {
let available = (stockitem?.quantity ?? 0) - (stockitem?.allocated ?? 0);