From d829d3a548f4a8fdbcc7ceffafe72cd1b15dd5c4 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 11 Nov 2025 17:29:18 +1100 Subject: [PATCH] [UI] Order form improvements (#10802) * Auto-fill supplier parts in order wizard * Copy supplier part SKU from order parts wizard * Add "on_order" filter to BuildLine table * Allow ordering by production and ordering quantities * Allow specification of purchase price * Bump API version * Adjust UI testings --- src/backend/InvenTree/InvenTree/api_version.py | 8 ++++++-- src/backend/InvenTree/build/api.py | 11 +++++++++++ src/frontend/src/components/buttons/CopyButton.tsx | 14 +++++++++++++- .../src/components/wizards/OrderPartsWizard.tsx | 10 ++++++++++ src/frontend/src/forms/PurchaseOrderForms.tsx | 2 +- src/frontend/src/tables/build/BuildLineTable.tsx | 12 ++++++++++-- .../tests/pages/pui_purchase_order.spec.ts | 4 +++- 7 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index b609e98729..2751a14c2c 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -1,12 +1,16 @@ """InvenTree API version information.""" # InvenTree API version -INVENTREE_API_VERSION = 424 +INVENTREE_API_VERSION = 425 """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" INVENTREE_API_TEXT = """ -v424 -> 2025-11-05 : https://github.com/inventree/InvenTree/pull/10730 +v425 -> 2025-11-11 : https://github.com/inventree/InvenTree/pull/10802 + - Adds "on_order" filter to the BuildLine API endpoint + - Allow BuildLine list to be ordered by "on_order" and "in_production" fields + +v424 -> 2025-11-11 : https://github.com/inventree/InvenTree/pull/10730 - Adds more lower / upper bounds to integer fields in the API schema due to bump to Django 5.2- no functional changes v423 -> 2025-11-05 : https://github.com/inventree/InvenTree/pull/10772 diff --git a/src/backend/InvenTree/build/api.py b/src/backend/InvenTree/build/api.py index 60aad418a0..2f0cf3d2ab 100644 --- a/src/backend/InvenTree/build/api.py +++ b/src/backend/InvenTree/build/api.py @@ -520,6 +520,15 @@ class BuildLineFilter(FilterSet): return queryset.filter(flt) return queryset.exclude(flt) + on_order = rest_filters.BooleanFilter(label=_('On Order'), method='filter_on_order') + + def filter_on_order(self, queryset, name, value): + """Filter by whether there is stock on order for each BuildLine.""" + if str2bool(value): + return queryset.filter(on_order__gt=0) + else: + return queryset.filter(on_order=0) + class BuildLineMixin(SerializerContextMixin): """Mixin class for BuildLine API endpoints.""" @@ -606,6 +615,8 @@ class BuildLineList( 'trackable', 'allow_variants', 'inherited', + 'on_order', + 'scheduled_to_build', ] ordering_field_aliases = { diff --git a/src/frontend/src/components/buttons/CopyButton.tsx b/src/frontend/src/components/buttons/CopyButton.tsx index dff4a42588..b9e283daa9 100644 --- a/src/frontend/src/components/buttons/CopyButton.tsx +++ b/src/frontend/src/components/buttons/CopyButton.tsx @@ -3,6 +3,7 @@ import { ActionIcon, Button, type DefaultMantineColor, + type FloatingPosition, CopyButton as MantineCopyButton, type MantineSize, Text, @@ -16,12 +17,18 @@ import type { JSX } from 'react'; export function CopyButton({ value, label, + tooltip, + disabled, + tooltipPosition, content, size, color = 'gray' }: Readonly<{ value: any; label?: string; + tooltip?: string; + disabled?: boolean; + tooltipPosition?: FloatingPosition; content?: JSX.Element; size?: MantineSize; color?: DefaultMantineColor; @@ -31,8 +38,13 @@ export function CopyButton({ return ( {({ copied, copy }) => ( - + { onSelectSupplierPart(record.part.pk, instance); @@ -312,6 +316,12 @@ function SelectPartsStep({ }} /> + , value: purchasePrice, diff --git a/src/frontend/src/tables/build/BuildLineTable.tsx b/src/frontend/src/tables/build/BuildLineTable.tsx index 03b1e37881..a58c4ccca1 100644 --- a/src/frontend/src/tables/build/BuildLineTable.tsx +++ b/src/frontend/src/tables/build/BuildLineTable.tsx @@ -190,7 +190,7 @@ export default function BuildLineTable({ { name: 'available', label: t`Available`, - description: t`Show items with available stock` + description: t`Show items with sufficient available stock` }, { name: 'consumable', @@ -217,6 +217,11 @@ export default function BuildLineTable({ label: t`Tracked`, description: t`Show tracked lines` }, + { + name: 'on_order', + label: t`On Order`, + description: t`Show items with stock on order` + }, PartCategoryFilter() ]; }, []); @@ -455,6 +460,8 @@ export default function BuildLineTable({ }, { accessor: 'in_production', + sortable: true, + ordering: 'scheduled_to_build', render: (record: any) => { if (record.scheduled_to_build > 0) { return ( @@ -471,7 +478,8 @@ export default function BuildLineTable({ }, DecimalColumn({ accessor: 'on_order', - defaultVisible: false + defaultVisible: false, + sortable: true }), { accessor: 'allocated', diff --git a/src/frontend/tests/pages/pui_purchase_order.spec.ts b/src/frontend/tests/pages/pui_purchase_order.spec.ts index 2b71c6383d..9d4a3ff552 100644 --- a/src/frontend/tests/pages/pui_purchase_order.spec.ts +++ b/src/frontend/tests/pages/pui_purchase_order.spec.ts @@ -263,7 +263,9 @@ test('Purchase Orders - Order Parts', async ({ browser }) => { // Select supplier part await page.getByLabel('related-field-supplier_part').click(); - await page.getByText('WM1731-ND').click(); + await page + .getByRole('option', { name: 'Thumbnail DigiKey WM1731-ND' }) + .click(); // Option to create a new supplier part await page.getByLabel('action-button-new-supplier-part').click();