mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-03 04:00:57 +00:00
[API] Return stock item list when creating multiple items (#9857)
* Return stock item information when serializing an existing item * Handle stock item creation * Commonize response * Provide build items in response * Formalize returned data type * Fix unit test
This commit is contained in:
@ -33,6 +33,7 @@ import { ModelType } from '@lib/enums/ModelType';
|
||||
import { UserRoles } from '@lib/enums/Roles';
|
||||
import { apiUrl } from '@lib/functions/Api';
|
||||
import { getDetailUrl } from '@lib/functions/Navigation';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import { useBarcodeScanDialog } from '../../components/barcodes/BarcodeScanDialog';
|
||||
import { ActionButton } from '../../components/buttons/ActionButton';
|
||||
import AdminButton from '../../components/buttons/AdminButton';
|
||||
@ -682,7 +683,23 @@ export default function StockDetail() {
|
||||
...duplicateStockData
|
||||
},
|
||||
follow: true,
|
||||
modelType: ModelType.stockitem
|
||||
successMessage: null,
|
||||
modelType: ModelType.stockitem,
|
||||
onFormSuccess: (data) => {
|
||||
// Handle case where multiple stock items are created
|
||||
if (Array.isArray(data) && data.length > 0) {
|
||||
if (data.length == 1) {
|
||||
navigate(getDetailUrl(ModelType.stockitem, data[0]?.pk));
|
||||
} else {
|
||||
const n: number = data.length;
|
||||
notifications.show({
|
||||
title: t`Items Created`,
|
||||
message: t`Created ${n} stock items`,
|
||||
color: 'green'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const preDeleteContent = useMemo(() => {
|
||||
|
@ -563,8 +563,7 @@ export function StockItemTable({
|
||||
const can_delete_stock = user.hasDeleteRole(UserRoles.stock);
|
||||
const can_add_stock = user.hasAddRole(UserRoles.stock);
|
||||
const can_add_stocktake = user.hasAddRole(UserRoles.stocktake);
|
||||
const can_add_order = user.hasAddRole(UserRoles.purchase_order);
|
||||
const can_change_order = user.hasChangeRole(UserRoles.purchase_order);
|
||||
|
||||
return [
|
||||
<ActionDropdown
|
||||
key='stock-actions'
|
||||
|
Reference in New Issue
Block a user