mirror of
https://github.com/inventree/InvenTree.git
synced 2026-01-28 09:03:41 +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:
@@ -1,4 +1,3 @@
|
|||||||
import { ApiEndpoints, ModelType, apiUrl } from '@lib/index';
|
|
||||||
import type { ApiFormFieldSet } from '@lib/types/Forms';
|
import type { ApiFormFieldSet } from '@lib/types/Forms';
|
||||||
import { t } from '@lingui/core/macro';
|
import { t } from '@lingui/core/macro';
|
||||||
import { IconBuildingStore, IconCopy, IconPackages } from '@tabler/icons-react';
|
import { IconBuildingStore, IconCopy, IconPackages } from '@tabler/icons-react';
|
||||||
@@ -10,8 +9,10 @@ import { useGlobalSettingsState } from '../states/SettingsStates';
|
|||||||
*/
|
*/
|
||||||
export function usePartFields({
|
export function usePartFields({
|
||||||
create = false,
|
create = false,
|
||||||
|
partId,
|
||||||
duplicatePartInstance
|
duplicatePartInstance
|
||||||
}: {
|
}: {
|
||||||
|
partId?: number;
|
||||||
duplicatePartInstance?: any;
|
duplicatePartInstance?: any;
|
||||||
create?: boolean;
|
create?: boolean;
|
||||||
}): ApiFormFieldSet {
|
}): ApiFormFieldSet {
|
||||||
@@ -55,10 +56,11 @@ export function usePartFields({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
default_supplier: {
|
default_supplier: {
|
||||||
model: ModelType.company,
|
hidden: !partId || !purchaseable,
|
||||||
api_url: apiUrl(ApiEndpoints.company_list),
|
|
||||||
filters: {
|
filters: {
|
||||||
is_supplier: true
|
part: partId,
|
||||||
|
part_detail: true,
|
||||||
|
supplier_detail: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
default_expiry: {},
|
default_expiry: {},
|
||||||
@@ -199,6 +201,7 @@ export function usePartFields({
|
|||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}, [
|
}, [
|
||||||
|
partId,
|
||||||
virtual,
|
virtual,
|
||||||
purchaseable,
|
purchaseable,
|
||||||
create,
|
create,
|
||||||
|
|||||||
@@ -501,13 +501,6 @@ export default function PartDetail() {
|
|||||||
model: ModelType.stocklocation,
|
model: ModelType.stocklocation,
|
||||||
hidden: part.default_location || !part.category_default_location
|
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',
|
type: 'string',
|
||||||
name: 'units',
|
name: 'units',
|
||||||
@@ -704,6 +697,9 @@ export default function PartDetail() {
|
|||||||
name: 'default_supplier',
|
name: 'default_supplier',
|
||||||
label: t`Default Supplier`,
|
label: t`Default Supplier`,
|
||||||
model: ModelType.supplierpart,
|
model: ModelType.supplierpart,
|
||||||
|
model_formatter: (model: any) => {
|
||||||
|
return model.SKU;
|
||||||
|
},
|
||||||
hidden: !part.default_supplier
|
hidden: !part.default_supplier
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1066,7 +1062,10 @@ export default function PartDetail() {
|
|||||||
];
|
];
|
||||||
}, [partRequirements, partRequirementsQuery.isFetching, part]);
|
}, [partRequirements, partRequirementsQuery.isFetching, part]);
|
||||||
|
|
||||||
const partFields = usePartFields({ create: false });
|
const partFields = usePartFields({
|
||||||
|
create: false,
|
||||||
|
partId: part.pk
|
||||||
|
});
|
||||||
|
|
||||||
const editPart = useEditApiFormModal({
|
const editPart = useEditApiFormModal({
|
||||||
url: ApiEndpoints.part_list,
|
url: ApiEndpoints.part_list,
|
||||||
|
|||||||
Reference in New Issue
Block a user