2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-07 06:00:57 +00:00

[bug] Allocated items print fix (#9952)

* Fix label printing for SalesOrderAllocation table

- Need to provide custom lookup option

* Add label actions to BuildOrderAllocationTable
This commit is contained in:
Oliver
2025-07-04 10:38:51 +10:00
committed by GitHub
parent e7b27c9e2f
commit 3d9291d95f
4 changed files with 18 additions and 1 deletions

View File

@ -52,6 +52,7 @@ const PAGE_SIZES = [10, 15, 20, 25, 50, 100, 500];
* @param enableSearch : boolean - Enable search actions
* @param enableLabels : boolean - Enable printing of labels against selected items
* @param enableReports : boolean - Enable printing of reports against selected items
* @param printingAccessor : string - Accessor for label and report printing (default = 'pk')
* @param enablePagination : boolean - Enable pagination
* @param enableRefresh : boolean - Enable refresh actions
* @param enableColumnSwitching : boolean - Enable column switching
@ -82,6 +83,7 @@ export type InvenTreeTableProps<T = any> = {
enableColumnCaching?: boolean;
enableLabels?: boolean;
enableReports?: boolean;
printingAccessor?: string;
afterBulkDelete?: () => void;
barcodeActions?: React.ReactNode[];
tableFilters?: TableFilter[];
@ -115,6 +117,7 @@ const defaultInvenTreeTableProps: InvenTreeTableProps = {
enableSelection: false,
defaultSortColumn: '',
barcodeActions: [],
printingAccessor: 'pk',
tableFilters: [],
tableActions: []
};

View File

@ -25,6 +25,7 @@ import { Boundary } from '../components/Boundary';
import { ActionButton } from '../components/buttons/ActionButton';
import { ButtonMenu } from '../components/buttons/ButtonMenu';
import { PrintingActions } from '../components/buttons/PrintingActions';
import { resolveItem } from '../functions/conversion';
import useDataExport from '../hooks/UseDataExport';
import { useDeleteApiFormModal } from '../hooks/UseForm';
import { TableColumnSelect } from './ColumnSelect';
@ -140,6 +141,15 @@ export default function InvenTreeTableHeader({
return (tableState?.queryFilters?.size ?? 0) > 0;
}, [tableState.queryFilters]);
// Extract ID values for label and report printing
const printingIdValues = useMemo(() => {
return (
tableState.selectedRecords?.map((record) => {
return resolveItem(record, tableProps.printingAccessor ?? 'pk');
}) ?? []
);
}, [tableProps.printingAccessor, tableState.selectedRecords]);
return (
<>
{exportModal.modal}
@ -165,7 +175,7 @@ export default function InvenTreeTableHeader({
<Group justify='apart' grow wrap='nowrap'>
<Group justify='left' key='custom-actions' gap={5} wrap='nowrap'>
<PrintingActions
items={tableState.selectedIds}
items={printingIdValues}
modelType={tableProps.modelType}
enableLabels={tableProps.enableLabels}
enableReports={tableProps.enableReports}

View File

@ -266,6 +266,9 @@ export default function BuildAllocatedStockTable({
rowActions: rowActions,
tableActions: tableActions,
tableFilters: tableFilters,
enableLabels: true,
enableReports: true,
printingAccessor: 'stock_item',
modelField: modelField ?? 'stock_item',
modelType: modelTarget ?? ModelType.stockitem
}}

View File

@ -366,6 +366,7 @@ export default function SalesOrderAllocationTable({
modelField: modelField ?? 'order',
enableReports: !isSubTable,
enableLabels: !isSubTable,
printingAccessor: 'item',
modelType: modelTarget ?? ModelType.salesorder
}}
/>