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) => {
|
.then((response) => {
|
||||||
|
const followPk = Array.isArray(response.data)
|
||||||
|
? response.data.length === 1
|
||||||
|
? response.data[0]?.pk
|
||||||
|
: undefined
|
||||||
|
: response.data?.pk;
|
||||||
|
|
||||||
switch (response.status) {
|
switch (response.status) {
|
||||||
case 200:
|
case 200:
|
||||||
case 201:
|
case 201:
|
||||||
@@ -469,12 +475,12 @@ export function ApiForm({
|
|||||||
if (
|
if (
|
||||||
props.follow &&
|
props.follow &&
|
||||||
props.modelType &&
|
props.modelType &&
|
||||||
response.data?.pk &&
|
followPk &&
|
||||||
!keepOpenRef.current
|
!keepOpenRef.current
|
||||||
) {
|
) {
|
||||||
// If we want to automatically follow the returned data
|
// If we want to automatically follow the returned data
|
||||||
if (!!navigate && !keepOpenRef.current) {
|
if (!!navigate && !keepOpenRef.current) {
|
||||||
navigate(getDetailUrl(props.modelType, response.data?.pk));
|
navigate(getDetailUrl(props.modelType, followPk));
|
||||||
}
|
}
|
||||||
} else if (props.table) {
|
} else if (props.table) {
|
||||||
// If we want to automatically update or reload a linked table
|
// If we want to automatically update or reload a linked table
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { t } from '@lingui/core/macro';
|
import { t } from '@lingui/core/macro';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
|
|
||||||
import { ActionButton } from '@lib/components/ActionButton';
|
import { ActionButton } from '@lib/components/ActionButton';
|
||||||
import { AddItemButton } from '@lib/components/AddItemButton';
|
import { AddItemButton } from '@lib/components/AddItemButton';
|
||||||
@@ -8,7 +7,6 @@ import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
|
|||||||
import { ModelType } from '@lib/enums/ModelType';
|
import { ModelType } from '@lib/enums/ModelType';
|
||||||
import { UserRoles } from '@lib/enums/Roles';
|
import { UserRoles } from '@lib/enums/Roles';
|
||||||
import { apiUrl } from '@lib/functions/Api';
|
import { apiUrl } from '@lib/functions/Api';
|
||||||
import { getDetailUrl } from '@lib/functions/Navigation';
|
|
||||||
import useTable from '@lib/hooks/UseTable';
|
import useTable from '@lib/hooks/UseTable';
|
||||||
import type { TableFilter } from '@lib/types/Filters';
|
import type { TableFilter } from '@lib/types/Filters';
|
||||||
import type { StockOperationProps } from '@lib/types/Forms';
|
import type { StockOperationProps } from '@lib/types/Forms';
|
||||||
@@ -381,8 +379,6 @@ export function StockItemTable({
|
|||||||
[settings]
|
[settings]
|
||||||
);
|
);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const tableColumns = useMemo(
|
const tableColumns = useMemo(
|
||||||
() =>
|
() =>
|
||||||
stockItemTableColumns({
|
stockItemTableColumns({
|
||||||
@@ -433,11 +429,7 @@ export function StockItemTable({
|
|||||||
},
|
},
|
||||||
follow: params.openNewStockItem ?? true,
|
follow: params.openNewStockItem ?? true,
|
||||||
table: table,
|
table: table,
|
||||||
onFormSuccess: (response: any) => {
|
modelType: ModelType.stockitem,
|
||||||
// Returns a list that may contain multiple serialized stock items
|
|
||||||
// Navigate to the first result
|
|
||||||
navigate(getDetailUrl(ModelType.stockitem, response[0].pk));
|
|
||||||
},
|
|
||||||
successMessage: t`Stock item created`,
|
successMessage: t`Stock item created`,
|
||||||
keepOpenOption: true
|
keepOpenOption: true
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user