2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-04-25 04:23:33 +00:00

[UI] Create manufacturer part (#11792)

- Create new manufacturer part from supplier part form
- Closes https://github.com/inventree/InvenTree/issues/10924
This commit is contained in:
Oliver
2026-04-24 09:41:24 +10:00
committed by GitHub
parent 389e49c218
commit e43d619d69
+17 -2
View File
@@ -12,7 +12,7 @@ import {
IconPackage, IconPackage,
IconPhone IconPhone
} from '@tabler/icons-react'; } from '@tabler/icons-react';
import { useMemo } from 'react'; import { useMemo, useState } from 'react';
/** /**
* Field set for SupplierPart instance * Field set for SupplierPart instance
@@ -26,6 +26,8 @@ export function useSupplierPartFields({
manufacturerPartId?: number; manufacturerPartId?: number;
partId?: number; partId?: number;
}) { }) {
const [part, setPart] = useState<any>({});
return useMemo(() => { return useMemo(() => {
const fields: ApiFormFieldSet = { const fields: ApiFormFieldSet = {
part: { part: {
@@ -35,6 +37,9 @@ export function useSupplierPartFields({
part: partId, part: partId,
purchaseable: true, purchaseable: true,
active: true active: true
},
onValueChange: (value: any, record: any) => {
setPart(record);
} }
}, },
manufacturer_part: { manufacturer_part: {
@@ -50,6 +55,16 @@ export function useSupplierPartFields({
...adjust.filters, ...adjust.filters,
part: adjust.data.part part: adjust.data.part
}; };
},
addCreateFields: {
part: {
value: part?.pk,
disabled: !!part?.pk
},
manufacturer: {},
MPN: {},
description: {},
link: {}
} }
}, },
supplier: { supplier: {
@@ -82,7 +97,7 @@ export function useSupplierPartFields({
}; };
return fields; return fields;
}, [manufacturerId, manufacturerPartId, partId]); }, [manufacturerId, manufacturerPartId, partId, part]);
} }
export function useManufacturerPartFields() { export function useManufacturerPartFields() {