From 90f726e325aece91244dbb81223a4ca7d7ba9d04 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 20 Oct 2024 15:01:05 +1100 Subject: [PATCH] [PUI] Tweaks for part purchase order table (#8319) * Improve API query * Table ordering fixes for PartPurchaseOrdersTable --- src/backend/InvenTree/order/api.py | 2 ++ src/frontend/src/tables/ColumnRenderers.tsx | 3 +++ src/frontend/src/tables/part/PartPurchaseOrdersTable.tsx | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/src/backend/InvenTree/order/api.py b/src/backend/InvenTree/order/api.py index dec97d4d2d04..c32282c37b72 100644 --- a/src/backend/InvenTree/order/api.py +++ b/src/backend/InvenTree/order/api.py @@ -550,6 +550,7 @@ def create(self, request, *args, **kwargs): 'SKU': 'part__SKU', 'part_name': 'part__part__name', 'order': 'order__reference', + 'status': 'order__status', 'complete_date': 'order__complete_date', } @@ -564,6 +565,7 @@ def create(self, request, *args, **kwargs): 'total_price', 'target_date', 'order', + 'status', 'complete_date', ] diff --git a/src/frontend/src/tables/ColumnRenderers.tsx b/src/frontend/src/tables/ColumnRenderers.tsx index 0f53d26b7973..371cc58eb4ab 100644 --- a/src/frontend/src/tables/ColumnRenderers.tsx +++ b/src/frontend/src/tables/ColumnRenderers.tsx @@ -174,6 +174,7 @@ export function ProjectCodeColumn(props: TableColumnProps): TableColumn { export function StatusColumn({ model, sortable, + ordering, accessor, title, hidden @@ -181,12 +182,14 @@ export function StatusColumn({ model: ModelType; sortable?: boolean; accessor?: string; + ordering?: string; hidden?: boolean; title?: string; }) { return { accessor: accessor ?? 'status', sortable: sortable ?? true, + ordering: ordering, title: title, hidden: hidden, render: TableStatusRenderer(model, accessor ?? 'status_custom_key') diff --git a/src/frontend/src/tables/part/PartPurchaseOrdersTable.tsx b/src/frontend/src/tables/part/PartPurchaseOrdersTable.tsx index d9878bbdeb5a..6c2057966ec7 100644 --- a/src/frontend/src/tables/part/PartPurchaseOrdersTable.tsx +++ b/src/frontend/src/tables/part/PartPurchaseOrdersTable.tsx @@ -25,6 +25,7 @@ export default function PartPurchaseOrdersTable({ return [ ReferenceColumn({ accessor: 'order_detail.reference', + ordering: 'order', sortable: true, switchable: false, title: t`Purchase Order` @@ -32,6 +33,7 @@ export default function PartPurchaseOrdersTable({ StatusColumn({ accessor: 'order_detail.status', sortable: true, + ordering: 'status', title: t`Status`, model: ModelType.purchaseorder }), @@ -55,6 +57,7 @@ export default function PartPurchaseOrdersTable({ }, { accessor: 'quantity', + sortable: true, switchable: false, render: (record: any) => { let supplier_part = record?.supplier_part_detail ?? {}; @@ -100,6 +103,11 @@ export default function PartPurchaseOrdersTable({ accessor: 'target_date', title: t`Target Date` }), + DateColumn({ + accessor: 'order_detail.complete_date', + ordering: 'complete_date', + title: t`Completion Date` + }), { accessor: 'purchase_price', render: (record: any) =>