mirror of
https://github.com/inventree/InvenTree.git
synced 2026-07-04 06:00:38 +00:00
fix: preserve supplier import stock workflow (#12215)
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
@@ -455,6 +455,12 @@ export function ApiForm({
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
const followPk = Array.isArray(response.data)
|
||||
? response.data.length === 1
|
||||
? response.data[0]?.pk
|
||||
: undefined
|
||||
: response.data?.pk;
|
||||
|
||||
switch (response.status) {
|
||||
case 200:
|
||||
case 201:
|
||||
@@ -469,12 +475,12 @@ export function ApiForm({
|
||||
if (
|
||||
props.follow &&
|
||||
props.modelType &&
|
||||
response.data?.pk &&
|
||||
followPk &&
|
||||
!keepOpenRef.current
|
||||
) {
|
||||
// If we want to automatically follow the returned data
|
||||
if (!!navigate && !keepOpenRef.current) {
|
||||
navigate(getDetailUrl(props.modelType, response.data?.pk));
|
||||
navigate(getDetailUrl(props.modelType, followPk));
|
||||
}
|
||||
} else if (props.table) {
|
||||
// If we want to automatically update or reload a linked table
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { ActionButton } from '@lib/components/ActionButton';
|
||||
import { AddItemButton } from '@lib/components/AddItemButton';
|
||||
@@ -8,7 +7,6 @@ import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
|
||||
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 useTable from '@lib/hooks/UseTable';
|
||||
import type { TableFilter } from '@lib/types/Filters';
|
||||
import type { StockOperationProps } from '@lib/types/Forms';
|
||||
@@ -381,8 +379,6 @@ export function StockItemTable({
|
||||
[settings]
|
||||
);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const tableColumns = useMemo(
|
||||
() =>
|
||||
stockItemTableColumns({
|
||||
@@ -433,11 +429,7 @@ export function StockItemTable({
|
||||
},
|
||||
follow: params.openNewStockItem ?? true,
|
||||
table: table,
|
||||
onFormSuccess: (response: any) => {
|
||||
// Returns a list that may contain multiple serialized stock items
|
||||
// Navigate to the first result
|
||||
navigate(getDetailUrl(ModelType.stockitem, response[0].pk));
|
||||
},
|
||||
modelType: ModelType.stockitem,
|
||||
successMessage: t`Stock item created`,
|
||||
keepOpenOption: true
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user