mirror of
https://github.com/inventree/InvenTree.git
synced 2026-06-15 21:10:50 +00:00
2fe0eefa8f
* Add "active" field to Company model * Expose 'active' parameter to API * Fix default value * Add 'active' column to PUI * Update PUI table * Update company detail pages * Update API filters for SupplierPart and ManufacturerPart * Bump API version * Update order forms * Add edit action to SalesOrderDetail page * Enable editing of ReturnOrder * Typo fix * Adds explicit "active" field to SupplierPart model * More updates - Add "inactive" badge to SupplierPart page - Update SupplierPartTable - Update backend API fields * Update ReturnOrderTable - Also some refactoring * Impove usePurchaseOrderLineItemFields hook * Cleanup * Implement duplicate action for SupplierPart * Fix for ApiForm - Only override initialValues for specified fields * Allow edit and duplicate of StockItem * Fix for ApiForm - Default values were overriding initial data * Add duplicate part option * Cleanup ApiForm - Cache props.fields * Fix unused import * More fixes * Add unit tests * Allow ordering company by 'active' status * Update docs * Merge migrations * Fix for serializers.py * Force new form value * Remove debug call * Further unit test fixes * Update default CSRF_TRUSTED_ORIGINS values * Reduce debug output
90 lines
2.0 KiB
TypeScript
90 lines
2.0 KiB
TypeScript
import { IconAddressBook, IconUser, IconUsers } from '@tabler/icons-react';
|
|
import { useMemo } from 'react';
|
|
|
|
import {
|
|
ApiFormAdjustFilterType,
|
|
ApiFormFieldSet
|
|
} from '../components/forms/fields/ApiFormField';
|
|
|
|
export function useSalesOrderFields(): ApiFormFieldSet {
|
|
return useMemo(() => {
|
|
return {
|
|
reference: {},
|
|
description: {},
|
|
customer: {
|
|
filters: {
|
|
is_customer: true,
|
|
active: true
|
|
}
|
|
},
|
|
customer_reference: {},
|
|
project_code: {},
|
|
order_currency: {},
|
|
target_date: {},
|
|
link: {},
|
|
contact: {
|
|
icon: <IconUser />,
|
|
adjustFilters: (value: ApiFormAdjustFilterType) => {
|
|
return {
|
|
...value.filters,
|
|
company: value.data.customer
|
|
};
|
|
}
|
|
},
|
|
address: {
|
|
icon: <IconAddressBook />,
|
|
adjustFilters: (value: ApiFormAdjustFilterType) => {
|
|
return {
|
|
...value.filters,
|
|
company: value.data.customer
|
|
};
|
|
}
|
|
},
|
|
responsible: {
|
|
icon: <IconUsers />
|
|
}
|
|
};
|
|
}, []);
|
|
}
|
|
|
|
export function useReturnOrderFields(): ApiFormFieldSet {
|
|
return useMemo(() => {
|
|
return {
|
|
reference: {},
|
|
description: {},
|
|
customer: {
|
|
filters: {
|
|
is_customer: true,
|
|
active: true
|
|
}
|
|
},
|
|
customer_reference: {},
|
|
project_code: {},
|
|
order_currency: {},
|
|
target_date: {},
|
|
link: {},
|
|
contact: {
|
|
icon: <IconUser />,
|
|
adjustFilters: (value: ApiFormAdjustFilterType) => {
|
|
return {
|
|
...value.filters,
|
|
company: value.data.customer
|
|
};
|
|
}
|
|
},
|
|
address: {
|
|
icon: <IconAddressBook />,
|
|
adjustFilters: (value: ApiFormAdjustFilterType) => {
|
|
return {
|
|
...value.filters,
|
|
company: value.data.customer
|
|
};
|
|
}
|
|
},
|
|
responsible: {
|
|
icon: <IconUsers />
|
|
}
|
|
};
|
|
}, []);
|
|
}
|