diff --git a/src/frontend/src/forms/StockForms.tsx b/src/frontend/src/forms/StockForms.tsx index 79215f379a..a8f015ba4f 100644 --- a/src/frontend/src/forms/StockForms.tsx +++ b/src/frontend/src/forms/StockForms.tsx @@ -2180,7 +2180,9 @@ export function useDeleteStockItem(props: StockOperationProps) { }); } -export function stockLocationFields(): ApiFormFieldSet { +export function useStockLocationFields(): ApiFormFieldSet { + const globalSettings = useGlobalSettingsState(); + const fields: ApiFormFieldSet = { parent: { description: t`Parent stock location`, @@ -2188,6 +2190,9 @@ export function stockLocationFields(): ApiFormFieldSet { }, name: {}, description: {}, + owner: { + icon: + }, structural: {}, external: {}, custom_icon: { @@ -2196,6 +2201,12 @@ export function stockLocationFields(): ApiFormFieldSet { location_type: {} }; + // Ownership of a stock location is only relevant if + // stock ownership control is enabled + if (!globalSettings.isSet('STOCK_OWNERSHIP_CONTROL')) { + delete fields.owner; + } + return fields; } diff --git a/src/frontend/src/pages/stock/LocationDetail.tsx b/src/frontend/src/pages/stock/LocationDetail.tsx index e2dba4347e..1342698721 100644 --- a/src/frontend/src/pages/stock/LocationDetail.tsx +++ b/src/frontend/src/pages/stock/LocationDetail.tsx @@ -38,7 +38,7 @@ import { PanelGroup } from '../../components/panels/PanelGroup'; import ParametersPanel from '../../components/panels/ParametersPanel'; import SegmentedControlPanel from '../../components/panels/SegmentedControlPanel'; import LocateItemButton from '../../components/plugins/LocateItemButton'; -import { stockLocationFields } from '../../forms/StockForms'; +import { useStockLocationFields } from '../../forms/StockForms'; import { InvenTreeIcon } from '../../functions/icons'; import { useDeleteApiFormModal, @@ -224,7 +224,7 @@ export default function Stock() { url: ApiEndpoints.stock_location_list, pk: id, title: t`Edit Stock Location`, - fields: stockLocationFields(), + fields: useStockLocationFields(), onFormSuccess: refreshInstance }); diff --git a/src/frontend/src/tables/stock/StockLocationTable.tsx b/src/frontend/src/tables/stock/StockLocationTable.tsx index d86a83ac73..35fd16617d 100644 --- a/src/frontend/src/tables/stock/StockLocationTable.tsx +++ b/src/frontend/src/tables/stock/StockLocationTable.tsx @@ -18,7 +18,7 @@ import { DescriptionColumn } from '../../components/tables/ColumnRenderers'; import { InvenTreeTable } from '../../components/tables/InvenTreeTable'; -import { stockLocationFields } from '../../forms/StockForms'; +import { useStockLocationFields } from '../../forms/StockForms'; import { InvenTreeIcon } from '../../functions/icons'; import { useBulkEditApiFormModal, @@ -109,7 +109,7 @@ export function StockLocationTable({ parentId }: Readonly<{ parentId?: any }>) { const newLocation = useCreateApiFormModal({ url: ApiEndpoints.stock_location_list, title: t`Add Stock Location`, - fields: stockLocationFields(), + fields: useStockLocationFields(), focus: 'name', initialData: { parent: parentId @@ -126,7 +126,7 @@ export function StockLocationTable({ parentId }: Readonly<{ parentId?: any }>) { url: ApiEndpoints.stock_location_list, pk: selectedLocation, title: t`Edit Stock Location`, - fields: stockLocationFields(), + fields: useStockLocationFields(), onFormSuccess: (record: any) => table.updateRecord(record) });