2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-29 08:01:35 +00:00

[PUI] Sales order actions ()

* [PUI] Add placeholder action

- "Allocate Serials" action for sales order
- No functionality yet

* Implement form for allocating by serial numbers

* Improve validation of serial numbers in back-end

* Trim serial number string
This commit is contained in:
Oliver
2024-09-06 14:33:16 +10:00
committed by GitHub
parent 3d9db2543d
commit 9f92475af0
4 changed files with 78 additions and 12 deletions
src
backend
InvenTree
frontend

@@ -152,6 +152,7 @@ export enum ApiEndpoints {
sales_order_extra_line_list = 'order/so-extra-line/',
sales_order_allocation_list = 'order/so-allocation/',
sales_order_shipment_list = 'order/so/shipment/',
sales_order_allocate_serials = 'order/so/:id/allocate-serials/',
return_order_list = 'order/ro/',
return_order_issue = 'order/ro/:id/issue/',

@@ -84,6 +84,31 @@ export function useSalesOrderLineItemFields({
return fields;
}
export function useSalesOrderAllocateSerialsFields({
itemId,
orderId
}: {
itemId: number;
orderId: number;
}): ApiFormFieldSet {
return useMemo(() => {
return {
line_item: {
value: itemId,
hidden: true
},
quantity: {},
serial_numbers: {},
shipment: {
filters: {
order: orderId,
shipped: false
}
}
};
}, [itemId, orderId]);
}
export function useSalesOrderShipmentFields(): ApiFormFieldSet {
return useMemo(() => {
return {

@@ -1,6 +1,7 @@
import { t } from '@lingui/macro';
import { Text } from '@mantine/core';
import {
IconHash,
IconShoppingCart,
IconSquareArrowRight,
IconTools
@@ -14,7 +15,10 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { ModelType } from '../../enums/ModelType';
import { UserRoles } from '../../enums/Roles';
import { useBuildOrderFields } from '../../forms/BuildForms';
import { useSalesOrderLineItemFields } from '../../forms/SalesOrderForms';
import {
useSalesOrderAllocateSerialsFields,
useSalesOrderLineItemFields
} from '../../forms/SalesOrderForms';
import { notYetImplemented } from '../../functions/notifications';
import {
useCreateApiFormModal,
@@ -223,6 +227,19 @@ export default function SalesOrderLineItemTable({
table: table
});
const allocateSerialFields = useSalesOrderAllocateSerialsFields({
itemId: selectedLine,
orderId: orderId
});
const allocateBySerials = useCreateApiFormModal({
url: ApiEndpoints.sales_order_allocate_serials,
pk: orderId,
title: t`Allocate Serial Numbers`,
fields: allocateSerialFields,
table: table
});
const buildOrderFields = useBuildOrderFields({ create: true });
const newBuildOrder = useCreateApiFormModal({
@@ -264,6 +281,20 @@ export default function SalesOrderLineItemTable({
color: 'green',
onClick: notYetImplemented
},
{
hidden:
!record?.part_detail?.trackable ||
allocated ||
!editable ||
!user.hasChangeRole(UserRoles.sales_order),
title: t`Allocate Serials`,
icon: <IconHash />,
color: 'green',
onClick: () => {
setSelectedLine(record.pk);
allocateBySerials.open();
}
},
{
hidden:
allocated ||
@@ -323,6 +354,7 @@ export default function SalesOrderLineItemTable({
{deleteLine.modal}
{newLine.modal}
{newBuildOrder.modal}
{allocateBySerials.modal}
<InvenTreeTable
url={apiUrl(ApiEndpoints.sales_order_line_list)}
tableState={table}