From 93a19b77f80a816b3483ebd5a4198bec713e5f74 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 28 Aug 2026 21:45:16 +1000 Subject: [PATCH] Add extra filtering options for supplier parts (#868) * Add extra filtering options for supplier parts * Update release notes * Allow edit of "primary" field --- assets/release_notes.md | 1 + lib/api.dart | 3 +++ lib/inventree/company.dart | 6 ++++++ lib/l10n/app_en.arb | 9 +++++++++ lib/widget/company/supplier_part_detail.dart | 15 +++++++++++++++ lib/widget/company/supplier_part_list.dart | 8 ++++++++ 6 files changed, 42 insertions(+) diff --git a/assets/release_notes.md b/assets/release_notes.md index 42f0a6f3..2ecfb8e2 100644 --- a/assets/release_notes.md +++ b/assets/release_notes.md @@ -1,6 +1,7 @@ ## 0.xx.y - August 2026 --- +- Additional filtering options for supplier parts - Additional barcode support using data intents - Improvements for build order display diff --git a/lib/api.dart b/lib/api.dart index da323d3b..303f80b6 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -326,6 +326,9 @@ class InvenTreeAPI { // Ref: https://github.com/inventree/InvenTree/pull/10699 bool get supportsModernParameters => apiVersion >= 429; + // Does the support support the "primary" field on SupplierPart model? + bool get supportsSupplierPartPrimaryField => apiVersion >= 456; + // Does the server use the new "user/me/" endpoints? // Ref: https://github.com/inventree/InvenTree/pull/11963 bool get supportsNewUserEndpoints => apiVersion >= 490; diff --git a/lib/inventree/company.dart b/lib/inventree/company.dart index 90ed77c1..a206987c 100644 --- a/lib/inventree/company.dart +++ b/lib/inventree/company.dart @@ -157,6 +157,10 @@ class InvenTreeSupplierPart extends InvenTreeModel { fields["active"] = {}; } + if (InvenTreeAPI().supportsSupplierPartPrimaryField) { + fields["primary"] = {}; + } + return fields; } @@ -198,6 +202,8 @@ class InvenTreeSupplierPart extends InvenTreeModel { bool get active => getBool("active", backup: true); + bool get primary => getBool("primary", backup: false); + int get partId => getInt("part"); double get inStock => getDouble("in_stock"); diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 194452eb..40982e69 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -612,6 +612,12 @@ "filterInProductionDetail": "Show parts in production", "@filterInProductionDetail": {}, + "filterPrimary": "Primary", + "@filterPrimary": {}, + + "filterPrimaryDetail": "Show primary supplier parts", + "@filterPrimaryDetail": {}, + "filterSerialized": "Serialized", "@filterSerialized": {}, @@ -1136,6 +1142,9 @@ "printLabel": "Print Label", "@printLabel": {}, + "primary": "Primary", + "@primary": {}, + "plugin": "Plugin", "@plugin": {}, diff --git a/lib/widget/company/supplier_part_detail.dart b/lib/widget/company/supplier_part_detail.dart index 97357d5e..d5b3d525 100644 --- a/lib/widget/company/supplier_part_detail.dart +++ b/lib/widget/company/supplier_part_detail.dart @@ -182,6 +182,21 @@ class _SupplierPartDisplayState ); } + if (api.supportsSupplierPartPrimaryField) { + tiles.add( + ListTile( + title: Text(L10().primary), + leading: Icon(TablerIcons.star, color: COLOR_ACTION), + trailing: Text( + widget.supplierPart.primary ? L10().yes : L10().no, + style: widget.supplierPart.primary + ? TextStyle(color: COLOR_SUCCESS) + : null, + ), + ), + ); + } + // Stock levels associated with this SupplierPart tiles.add( ListTile( diff --git a/lib/widget/company/supplier_part_list.dart b/lib/widget/company/supplier_part_list.dart index c820a67d..c4415d0d 100644 --- a/lib/widget/company/supplier_part_list.dart +++ b/lib/widget/company/supplier_part_list.dart @@ -65,6 +65,14 @@ class _PaginatedSupplierPartListState }; } + if (InvenTreeAPI().supportsSupplierPartPrimaryField) { + filters["primary"] = { + "label": L10().filterPrimary, + "help_text": L10().filterPrimaryDetail, + "tristate": true, + }; + } + return filters; }