2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-01 13:06:45 +00:00

PUI: Return item from customer (#8227)

- Add manual form to return a stock item from customer
This commit is contained in:
Oliver 2024-10-01 23:33:35 +10:00 committed by GitHub
parent c23f2828f5
commit 7bffa49f3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 2 deletions

View File

@ -136,6 +136,7 @@ export enum ApiEndpoints {
stock_install = 'stock/:id/install/',
stock_uninstall = 'stock/:id/uninstall/',
stock_serialize = 'stock/:id/serialize/',
stock_return = 'stock/:id/return/',
build_test_statistics = 'test-statistics/by-build/:id/',
part_test_statistics = 'test-statistics/by-part/:id/',

View File

@ -1,5 +1,5 @@
import { t } from '@lingui/macro';
import { Accordion, Grid, Skeleton, Stack } from '@mantine/core';
import { Accordion, Alert, Grid, Skeleton, Stack } from '@mantine/core';
import {
IconBookmark,
IconBoxPadding,
@ -42,7 +42,6 @@ import { formatCurrency } from '../../defaults/formatters';
import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { ModelType } from '../../enums/ModelType';
import { UserRoles } from '../../enums/Roles';
import { partCategoryFields } from '../../forms/PartForms';
import {
StockOperationProps,
useAddStockItem,
@ -608,6 +607,28 @@ export default function StockDetail() {
successMessage: t`Stock item serialized`
});
const returnStockItem = useCreateApiFormModal({
url: ApiEndpoints.stock_return,
pk: stockitem.pk,
title: t`Return Stock Item`,
preFormContent: (
<Alert color="blue">
{t`Return this item into stock. This will remove the customer assignment.`}
</Alert>
),
fields: {
location: {},
notes: {}
},
initialData: {
location: stockitem.location ?? stockitem.part_detail?.default_location
},
successMessage: t`Item returned to stock`,
onFormSuccess: () => {
refreshInstance();
}
});
const stockActions = useMemo(() => {
const serial = stockitem.serial;
const serialized =
@ -681,6 +702,20 @@ export default function StockDetail() {
onClick: () => {
stockitem.pk && transferStockItem.open();
}
},
{
name: t`Return`,
tooltip: t`Return from customer`,
hidden: !stockitem.customer,
icon: (
<InvenTreeIcon
icon="return_orders"
iconProps={{ color: 'blue' }}
/>
),
onClick: () => {
stockitem.pk && returnStockItem.open();
}
}
]}
/>,
@ -788,6 +823,7 @@ export default function StockDetail() {
{removeStockItem.modal}
{transferStockItem.modal}
{serializeStockItem.modal}
{returnStockItem.modal}
</Stack>
</InstanceDetail>
);