mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
[PUI] Update part duplicate forms (#7575)
- Enable copying of part details when duplicating a part - Update forms
This commit is contained in:
parent
8309eb628f
commit
3ce0202ffd
@ -603,6 +603,8 @@ class PartSerializer(
|
||||
Used when displaying all details of a single component.
|
||||
"""
|
||||
|
||||
import_exclude_fields = ['duplicate']
|
||||
|
||||
class Meta:
|
||||
"""Metaclass defining serializer fields."""
|
||||
|
||||
|
@ -57,7 +57,9 @@ export function usePartFields({
|
||||
fields.initial_stock = {
|
||||
icon: <IconPackages />,
|
||||
children: {
|
||||
quantity: {},
|
||||
quantity: {
|
||||
value: 0
|
||||
},
|
||||
location: {}
|
||||
}
|
||||
};
|
||||
|
@ -34,6 +34,7 @@ import { DetailsImage } from '../../components/details/DetailsImage';
|
||||
import { ItemDetailsGrid } from '../../components/details/ItemDetails';
|
||||
import { PartIcons } from '../../components/details/PartIcons';
|
||||
import NotesEditor from '../../components/editors/NotesEditor';
|
||||
import { ApiFormFieldSet } from '../../components/forms/fields/ApiFormField';
|
||||
import { Thumbnail } from '../../components/images/Thumbnail';
|
||||
import {
|
||||
ActionDropdown,
|
||||
@ -718,12 +719,34 @@ export default function PartDetail() {
|
||||
onFormSuccess: refreshInstance
|
||||
});
|
||||
|
||||
const createPartFields = usePartFields({ create: true });
|
||||
|
||||
const duplicatePartFields: ApiFormFieldSet = useMemo(() => {
|
||||
return {
|
||||
...createPartFields,
|
||||
duplicate: {
|
||||
children: {
|
||||
part: {
|
||||
value: part.pk,
|
||||
hidden: true
|
||||
},
|
||||
copy_image: {},
|
||||
copy_bom: {},
|
||||
copy_notes: {},
|
||||
copy_parameters: {}
|
||||
}
|
||||
}
|
||||
};
|
||||
}, [createPartFields, part]);
|
||||
|
||||
const duplicatePart = useCreateApiFormModal({
|
||||
url: ApiEndpoints.part_list,
|
||||
title: t`Add Part`,
|
||||
fields: partFields,
|
||||
fields: duplicatePartFields,
|
||||
initialData: {
|
||||
...part
|
||||
...part,
|
||||
active: true,
|
||||
locked: false
|
||||
},
|
||||
follow: true,
|
||||
modelType: ModelType.part
|
||||
|
Loading…
Reference in New Issue
Block a user