2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-01-28 17:13:44 +00:00

[UI] Default supplier fix (#11142)

* [UI] Fix "default supplier" form

- Select the supplier part instance

* Hide field if part is not purchaseable

* Fix supplier part display
This commit is contained in:
Oliver
2026-01-17 15:53:34 +11:00
committed by GitHub
parent c89e3bdfea
commit 59f93ca413
2 changed files with 14 additions and 12 deletions

View File

@@ -1,4 +1,3 @@
import { ApiEndpoints, ModelType, apiUrl } from '@lib/index';
import type { ApiFormFieldSet } from '@lib/types/Forms';
import { t } from '@lingui/core/macro';
import { IconBuildingStore, IconCopy, IconPackages } from '@tabler/icons-react';
@@ -10,8 +9,10 @@ import { useGlobalSettingsState } from '../states/SettingsStates';
*/
export function usePartFields({
create = false,
partId,
duplicatePartInstance
}: {
partId?: number;
duplicatePartInstance?: any;
create?: boolean;
}): ApiFormFieldSet {
@@ -55,10 +56,11 @@ export function usePartFields({
}
},
default_supplier: {
model: ModelType.company,
api_url: apiUrl(ApiEndpoints.company_list),
hidden: !partId || !purchaseable,
filters: {
is_supplier: true
part: partId,
part_detail: true,
supplier_detail: true
}
},
default_expiry: {},
@@ -199,6 +201,7 @@ export function usePartFields({
return fields;
}, [
partId,
virtual,
purchaseable,
create,

View File

@@ -501,13 +501,6 @@ export default function PartDetail() {
model: ModelType.stocklocation,
hidden: part.default_location || !part.category_default_location
},
{
type: 'link',
name: 'default_supplier',
label: t`Default Supplier`,
model: ModelType.company,
hidden: !part.default_supplier
},
{
type: 'string',
name: 'units',
@@ -704,6 +697,9 @@ export default function PartDetail() {
name: 'default_supplier',
label: t`Default Supplier`,
model: ModelType.supplierpart,
model_formatter: (model: any) => {
return model.SKU;
},
hidden: !part.default_supplier
},
{
@@ -1066,7 +1062,10 @@ export default function PartDetail() {
];
}, [partRequirements, partRequirementsQuery.isFetching, part]);
const partFields = usePartFields({ create: false });
const partFields = usePartFields({
create: false,
partId: part.pk
});
const editPart = useEditApiFormModal({
url: ApiEndpoints.part_list,