mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 19:45:46 +00:00
Scan in stock location
This commit is contained in:
@ -38,7 +38,6 @@ import {
|
|||||||
useTransferStockItem
|
useTransferStockItem
|
||||||
} from '../../forms/StockForms';
|
} from '../../forms/StockForms';
|
||||||
import { InvenTreeIcon } from '../../functions/icons';
|
import { InvenTreeIcon } from '../../functions/icons';
|
||||||
import { notYetImplemented } from '../../functions/notifications';
|
|
||||||
import {
|
import {
|
||||||
useDeleteApiFormModal,
|
useDeleteApiFormModal,
|
||||||
useEditApiFormModal
|
useEditApiFormModal
|
||||||
@ -275,7 +274,7 @@ export default function Stock() {
|
|||||||
const transferStockItems = useTransferStockItem(stockItemActionProps);
|
const transferStockItems = useTransferStockItem(stockItemActionProps);
|
||||||
const countStockItems = useCountStockItem(stockItemActionProps);
|
const countStockItems = useCountStockItem(stockItemActionProps);
|
||||||
|
|
||||||
const scanInStockItems = useBarcodeScanDialog({
|
const scanInStockItem = useBarcodeScanDialog({
|
||||||
title: t`Scan Stock Item`,
|
title: t`Scan Stock Item`,
|
||||||
modelType: ModelType.stockitem,
|
modelType: ModelType.stockitem,
|
||||||
callback: async (barcode, response) => {
|
callback: async (barcode, response) => {
|
||||||
@ -306,6 +305,31 @@ export default function Stock() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const scanInStockLocation = useBarcodeScanDialog({
|
||||||
|
title: t`Scan Stock Location`,
|
||||||
|
modelType: ModelType.stocklocation,
|
||||||
|
callback: async (barcode, response) => {
|
||||||
|
const pk = response.stocklocation.pk;
|
||||||
|
|
||||||
|
// Set the parent location
|
||||||
|
return api
|
||||||
|
.patch(apiUrl(ApiEndpoints.stock_location_list, pk), {
|
||||||
|
parent: location.pk
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return {
|
||||||
|
success: t`Scanned stock location into location`
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error scanning stock location:', error);
|
||||||
|
return {
|
||||||
|
error: t`Error scanning stock location`
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const locationActions = useMemo(
|
const locationActions = useMemo(
|
||||||
() => [
|
() => [
|
||||||
<AdminButton model={ModelType.stocklocation} id={location.pk} />,
|
<AdminButton model={ModelType.stocklocation} id={location.pk} />,
|
||||||
@ -321,13 +345,13 @@ export default function Stock() {
|
|||||||
name: 'Scan in stock items',
|
name: 'Scan in stock items',
|
||||||
icon: <InvenTreeIcon icon='stock' />,
|
icon: <InvenTreeIcon icon='stock' />,
|
||||||
tooltip: 'Scan items',
|
tooltip: 'Scan items',
|
||||||
onClick: scanInStockItems.open
|
onClick: scanInStockItem.open
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Scan in container',
|
name: 'Scan in container',
|
||||||
icon: <InvenTreeIcon icon='unallocated_stock' />,
|
icon: <InvenTreeIcon icon='unallocated_stock' />,
|
||||||
tooltip: 'Scan container',
|
tooltip: 'Scan container',
|
||||||
onClick: notYetImplemented
|
onClick: scanInStockLocation.open
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@ -396,7 +420,8 @@ export default function Stock() {
|
|||||||
<>
|
<>
|
||||||
{editLocation.modal}
|
{editLocation.modal}
|
||||||
{deleteLocation.modal}
|
{deleteLocation.modal}
|
||||||
{scanInStockItems.dialog}
|
{scanInStockItem.dialog}
|
||||||
|
{scanInStockLocation.dialog}
|
||||||
<InstanceDetail
|
<InstanceDetail
|
||||||
status={requestStatus}
|
status={requestStatus}
|
||||||
loading={id ? instanceQuery.isFetching : false}
|
loading={id ? instanceQuery.isFetching : false}
|
||||||
|
Reference in New Issue
Block a user