From 3c14c0cc0e6c5768b6ed6b0c50e47f67163f88fc Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 22 Nov 2026 21:55:25 +1100 Subject: [PATCH] Dead code (#935) * fix release notes styling * remove legacy code Removes checks for API versions that the app no longer supports --- assets/release_notes.md | 34 +++++++-------- lib/api.dart | 26 ++---------- lib/inventree/attachment.dart | 4 -- lib/inventree/company.dart | 26 ++---------- lib/inventree/model.dart | 13 +----- lib/inventree/notification.dart | 7 +--- lib/inventree/purchase_order.dart | 9 ---- lib/inventree/sales_order.dart | 5 --- lib/labels.dart | 6 --- lib/widget/attachment_widget.dart | 7 +--- lib/widget/build/build_detail.dart | 20 ++++----- lib/widget/company/company_detail.dart | 20 ++++----- lib/widget/company/company_list.dart | 12 +++--- .../company/manufacturer_part_detail.dart | 20 ++++----- lib/widget/company/supplier_part_detail.dart | 20 ++++----- lib/widget/company/supplier_part_list.dart | 12 +++--- lib/widget/order/purchase_order_detail.dart | 23 +++++----- lib/widget/order/sales_order_detail.dart | 20 ++++----- lib/widget/order/so_shipment_detail.dart | 20 ++++----- lib/widget/part/category_display.dart | 7 +--- lib/widget/part/category_list.dart | 13 +----- lib/widget/part/part_detail.dart | 42 +++++++++---------- lib/widget/stock/location_display.dart | 11 +---- lib/widget/stock/stock_detail.dart | 22 +++++----- test/order_models_test.dart | 15 ++++--- 25 files changed, 142 insertions(+), 272 deletions(-) diff --git a/assets/release_notes.md b/assets/release_notes.md index 9c3b2dbc..6dee9ed4 100644 --- a/assets/release_notes.md +++ b/assets/release_notes.md @@ -23,7 +23,7 @@ - Add "reference" ordering for BOM list - Bug fix for list widget ordering -## 1.0.0 - November 2026 +### 1.0.0 - November 2026 --- - Login now uses secure sessions, matching the web interface (API tokens are no longer used) @@ -35,7 +35,7 @@ - Requires InvenTree server API version 314 or newer - existing users must log in again - Updated translations -## 0.26.0 - October 2026 +### 0.26.0 - October 2026 --- - Supports new multi-note API for model instances @@ -45,7 +45,7 @@ - Adds support for separate "pricing" permission set - Updated translations -## 0.25.2 - September 2026 +### 0.25.2 - September 2026 --- - On stock transfer, add a merge option. @@ -53,28 +53,28 @@ - Bug fix for top level stock display - Bug fix for top level location display -## 0.25.1 - August 2026 +### 0.25.1 - August 2026 --- - Additional filtering options for supplier parts - Additional barcode support using data intents - Improvements for build order display -## 0.25.0 - July 2026 +### 0.25.0 - July 2026 --- - API speed improvements - Enable scanning of Build Order barcodes - Updated translations -## 0.24.3 - May 2026 +### 0.24.3 - May 2026 --- - Update file and image selection packages - Check for app updates - Updated translations -## 0.24.2 - May 2026 +### 0.24.2 - May 2026 --- - Display user information in the app drawer @@ -82,47 +82,47 @@ - Moves notifications to the top of the screen - Updated translations -## 0.24.1 - April 2026 +### 0.24.1 - April 2026 --- - Fixes bug which prevented label printing -## 0.24.0 - April 2026 +### 0.24.0 - April 2026 --- - Adds support for build order management - Updated translations -## 0.23.0 - April 2026 +### 0.23.0 - April 2026 --- - Fixes image artifact issues for iOS devices - Update underlying Flutter version -## 0.22.7 - March 2026 +### 0.22.7 - March 2026 --- - Bug fix for loading sales order shipments -## 0.22.6 - March 2026 +### 0.22.6 - March 2026 --- - Fix for displaying stock item test results -## 0.22.5 - March 2026 +### 0.22.5 - March 2026 --- - Fix default value for "cascade" filter in PartCategory list view - Fix default value for "cascade" filter in StockLocation list view -## 0.22.4 - March 2026 +### 0.22.4 - March 2026 --- - Adds button to check server connection - Fixes bug fetching sales order shipments - Fix for boolean fields in API forms -## 0.22.3 - February 2026 +### 0.22.3 - February 2026 --- - Auto-fill location data when receiving item via barcode scan @@ -130,12 +130,12 @@ - Add support for tri-state boolean form fields - Bug fixes for refreshing list view data -## 0.22.2 - February 2026 +### 0.22.2 - February 2026 --- - Bug fix for label printing, which used improperly formatted URL -## 0.22.1 - February 2026 +### 0.22.1 - February 2026 --- - Fixes bug related to fetching images from remote URLs diff --git a/lib/api.dart b/lib/api.dart index 0d7bbb94..0d0f624f 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -326,28 +326,8 @@ class InvenTreeAPI { * These functions are used to determine if the server supports a particular feature */ - // Does the server support "active" status on Company and SupplierPart API endpoints? - bool get supportsCompanyActiveStatus => apiVersion >= 189; - - // Does the server support the "modern" (consolidated) label printing API? - bool get supportsModernLabelPrinting => apiVersion >= 201; - - // Does the server support the "modern" (consolidated) attachment API? - // Ref: https://github.com/inventree/InvenTree/pull/7420 - bool get supportsModernAttachments => apiVersion >= 207; - - bool get supportsUserPermissions => apiVersion >= 207; - - // Ref: https://github.com/inventree/InvenTree/pull/7514 - bool get supportsTopLevelFiltering => apiVersion >= 209; - - // Does the server support the "destination" field on the PurchaseOrder model? - // Ref: https://github.com/inventree/InvenTree/pull/8403 - bool get supportsPurchaseOrderDestination => apiVersion >= 276; - - // Does the server support the "start_date" field for orders? - // Ref: https://github.com/inventree/InvenTree/pull/8966 - bool get supportsStartDate => apiVersion >= 306; + // Note: Features available at the minimum supported API version + // (see _minApiVersion) do not require a version check // Supports separate search against "supplier" / "customer" / "manufacturer" bool get supportsSplitCompanySearch => apiVersion >= 315; @@ -972,7 +952,7 @@ class InvenTreeAPI { roles = (data["roles"] ?? {}) as Map; - if (supportsUserPermissions && data.containsKey("permissions")) { + if (data.containsKey("permissions")) { permissions = (data["permissions"] ?? {}) as Map; } else { permissions = {}; diff --git a/lib/inventree/attachment.dart b/lib/inventree/attachment.dart index f89670e3..6b2c91c3 100644 --- a/lib/inventree/attachment.dart +++ b/lib/inventree/attachment.dart @@ -90,10 +90,6 @@ class InvenTreeAttachment extends InvenTreeModel { Future countAttachments(String modelType, int modelId) async { Map filters = {}; - if (!api.supportsModernAttachments) { - return 0; - } - filters["model_type"] = modelType; filters["model_id"] = modelId.toString(); diff --git a/lib/inventree/company.dart b/lib/inventree/company.dart index a206987c..a7bc5890 100644 --- a/lib/inventree/company.dart +++ b/lib/inventree/company.dart @@ -46,12 +46,9 @@ class InvenTreeCompany extends InvenTreeModel { "is_manufacturer": {}, "is_customer": {}, "currency": {}, + "active": {}, }; - if (InvenTreeAPI().supportsCompanyActiveStatus) { - fields["active"] = {}; - } - return fields; } @@ -144,19 +141,10 @@ class InvenTreeSupplierPart extends InvenTreeModel { "link": {}, "note": {}, "packaging": {}, + "pack_quantity": {}, + "active": {}, }; - // At some point, pack_size was changed to pack_quantity - if (InvenTreeAPI().apiVersion < 117) { - fields["pack_size"] = {}; - } else { - fields["pack_quantity"] = {}; - } - - if (InvenTreeAPI().supportsCompanyActiveStatus) { - fields["active"] = {}; - } - if (InvenTreeAPI().supportsSupplierPartPrimaryField) { fields["primary"] = {}; } @@ -224,13 +212,7 @@ class InvenTreeSupplierPart extends InvenTreeModel { String get packaging => getString("packaging"); - String get pack_quantity { - if (InvenTreeAPI().apiVersion < 117) { - return getString("pack_size"); - } else { - return getString("pack_quantity"); - } - } + String get pack_quantity => getString("pack_quantity"); @override InvenTreeModel createFromJson(Map json) => diff --git a/lib/inventree/model.dart b/lib/inventree/model.dart index 1a045155..08481785 100644 --- a/lib/inventree/model.dart +++ b/lib/inventree/model.dart @@ -912,18 +912,7 @@ class InvenTreePlugin extends InvenTreeModel { InvenTreePlugin.fromJson(json); @override - String get URL { - /* Note: The plugin API endpoint changed at API version 90, - * < 90 = 'plugin' - * >= 90 = 'plugins' - * Ref: https://github.com/inventree/InvenTree/pull/4186 - */ - if (api.isConnected() && api.apiVersion < 90) { - return "plugin/"; - } else { - return "plugins/"; - } - } + String get URL => "plugins/"; String get key => getString("key"); diff --git a/lib/inventree/notification.dart b/lib/inventree/notification.dart index eee28723..ff6e3697 100644 --- a/lib/inventree/notification.dart +++ b/lib/inventree/notification.dart @@ -38,11 +38,6 @@ class InvenTreeNotification extends InvenTreeModel { * Dismiss this notification (mark as read) */ Future dismiss() async { - if (api.apiVersion >= 82) { - // "Modern" API endpoint operates a little differently - await update(values: {"read": "true"}); - } else { - await api.post("${url}read/"); - } + await update(values: {"read": "true"}); } } diff --git a/lib/inventree/purchase_order.dart b/lib/inventree/purchase_order.dart index 020fd83c..88a0387b 100644 --- a/lib/inventree/purchase_order.dart +++ b/lib/inventree/purchase_order.dart @@ -1,6 +1,5 @@ import "package:flutter/material.dart"; import "package:flutter_tabler_icons/flutter_tabler_icons.dart"; -import "package:inventree/api.dart"; import "package:inventree/helpers.dart"; import "package:inventree/inventree/company.dart"; import "package:inventree/inventree/model.dart"; @@ -63,14 +62,6 @@ class InvenTreePurchaseOrder extends InvenTreeOrder { }, }; - if (!InvenTreeAPI().supportsPurchaseOrderDestination) { - fields.remove("destination"); - } - - if (!InvenTreeAPI().supportsStartDate) { - fields.remove("start_date"); - } - return fields; } diff --git a/lib/inventree/sales_order.dart b/lib/inventree/sales_order.dart index 4ea742e0..159845e5 100644 --- a/lib/inventree/sales_order.dart +++ b/lib/inventree/sales_order.dart @@ -1,5 +1,4 @@ import "package:flutter/material.dart"; -import "package:inventree/api.dart"; import "package:inventree/helpers.dart"; import "package:inventree/inventree/company.dart"; @@ -62,10 +61,6 @@ class InvenTreeSalesOrder extends InvenTreeOrder { }, }; - if (!InvenTreeAPI().supportsStartDate) { - fields.remove("start_date"); - } - return fields; } diff --git a/lib/labels.dart b/lib/labels.dart index e0ede349..80e13862 100644 --- a/lib/labels.dart +++ b/lib/labels.dart @@ -331,12 +331,6 @@ Future selectAndPrintLabel( return; } - if (!InvenTreeAPI().supportsModernLabelPrinting) { - // Legacy label printing API not supported - showSnackIcon("Label printing not supported by server", success: false); - return; - } - // Fetch default values for label printing // Default template diff --git a/lib/widget/attachment_widget.dart b/lib/widget/attachment_widget.dart index 7ed39f2e..fcd622c5 100644 --- a/lib/widget/attachment_widget.dart +++ b/lib/widget/attachment_widget.dart @@ -2,7 +2,6 @@ import "dart:io"; import "package:flutter/material.dart"; import "package:flutter_tabler_icons/flutter_tabler_icons.dart"; -import "package:inventree/api.dart"; import "package:inventree/inventree/attachment.dart"; import "package:inventree/widget/link_icon.dart"; import "package:one_context/one_context.dart"; @@ -253,7 +252,7 @@ class _AttachmentWidgetState extends RefreshableState { /* * Return a ListTile to display attachments for the specified model */ -ListTile? ShowAttachmentsItem( +ListTile ShowAttachmentsItem( BuildContext context, String modelType, int modelId, @@ -261,10 +260,6 @@ ListTile? ShowAttachmentsItem( int attachmentCount, bool hasUploadPermission, ) { - if (!InvenTreeAPI().supportsModernAttachments) { - return null; - } - return ListTile( title: Text(L10().attachments), leading: Icon(TablerIcons.file, color: COLOR_ACTION), diff --git a/lib/widget/build/build_detail.dart b/lib/widget/build/build_detail.dart index 0789c419..3cc6f0e6 100644 --- a/lib/widget/build/build_detail.dart +++ b/lib/widget/build/build_detail.dart @@ -637,19 +637,17 @@ class _BuildOrderDetailState extends RefreshableState { } // Attachments tile - ListTile? attachmentTile = ShowAttachmentsItem( - context, - InvenTreeBuildOrder.MODEL_TYPE, - widget.order.pk, - widget.order.reference, - attachmentCount, - widget.order.canEdit, + tiles.add( + ShowAttachmentsItem( + context, + InvenTreeBuildOrder.MODEL_TYPE, + widget.order.pk, + widget.order.reference, + attachmentCount, + widget.order.canEdit, + ), ); - if (attachmentTile != null) { - tiles.add(attachmentTile); - } - return tiles; } diff --git a/lib/widget/company/company_detail.dart b/lib/widget/company/company_detail.dart index 818cd05e..7ee9aed1 100644 --- a/lib/widget/company/company_detail.dart +++ b/lib/widget/company/company_detail.dart @@ -428,19 +428,17 @@ class _CompanyDetailState extends RefreshableState { tiles.add(parameterTile); } - ListTile? attachmentTile = ShowAttachmentsItem( - context, - InvenTreeCompany.MODEL_TYPE, - widget.company.pk, - widget.company.name, - attachmentCount, - widget.company.canEdit, + tiles.add( + ShowAttachmentsItem( + context, + InvenTreeCompany.MODEL_TYPE, + widget.company.pk, + widget.company.name, + attachmentCount, + widget.company.canEdit, + ), ); - if (attachmentTile != null) { - tiles.add(attachmentTile); - } - return tiles; } } diff --git a/lib/widget/company/company_list.dart b/lib/widget/company/company_list.dart index e544db2a..1a78bd92 100644 --- a/lib/widget/company/company_list.dart +++ b/lib/widget/company/company_list.dart @@ -94,13 +94,11 @@ class _CompanyListState extends PaginatedSearchState { Map> get filterOptions { Map> filters = {}; - if (InvenTreeAPI().supportsCompanyActiveStatus) { - filters["active"] = { - "label": L10().filterActive, - "help_text": L10().filterActiveDetail, - "tristate": true, - }; - } + filters["active"] = { + "label": L10().filterActive, + "help_text": L10().filterActiveDetail, + "tristate": true, + }; return filters; } diff --git a/lib/widget/company/manufacturer_part_detail.dart b/lib/widget/company/manufacturer_part_detail.dart index c288d4ab..f78b0271 100644 --- a/lib/widget/company/manufacturer_part_detail.dart +++ b/lib/widget/company/manufacturer_part_detail.dart @@ -230,19 +230,17 @@ class _ManufacturerPartDisplayState tiles.add(parameterTile); } - ListTile? attachmentTile = ShowAttachmentsItem( - context, - InvenTreeManufacturerPart.MODEL_TYPE, - widget.manufacturerPart.pk, - widget.manufacturerPart.MPN, - attachmentCount, - widget.manufacturerPart.canEdit, + tiles.add( + ShowAttachmentsItem( + context, + InvenTreeManufacturerPart.MODEL_TYPE, + widget.manufacturerPart.pk, + widget.manufacturerPart.MPN, + attachmentCount, + widget.manufacturerPart.canEdit, + ), ); - if (attachmentTile != null) { - tiles.add(attachmentTile); - } - return tiles; } } diff --git a/lib/widget/company/supplier_part_detail.dart b/lib/widget/company/supplier_part_detail.dart index fe9d1532..51f96f60 100644 --- a/lib/widget/company/supplier_part_detail.dart +++ b/lib/widget/company/supplier_part_detail.dart @@ -362,19 +362,17 @@ class _SupplierPartDisplayState tiles.add(parameterTile); } - ListTile? attachmentTile = ShowAttachmentsItem( - context, - InvenTreeSupplierPart.MODEL_TYPE, - widget.supplierPart.pk, - widget.supplierPart.SKU, - attachmentCount, - widget.supplierPart.canEdit, + tiles.add( + ShowAttachmentsItem( + context, + InvenTreeSupplierPart.MODEL_TYPE, + widget.supplierPart.pk, + widget.supplierPart.SKU, + attachmentCount, + widget.supplierPart.canEdit, + ), ); - if (attachmentTile != null) { - tiles.add(attachmentTile); - } - return tiles; } } diff --git a/lib/widget/company/supplier_part_list.dart b/lib/widget/company/supplier_part_list.dart index c4415d0d..bc7ed97a 100644 --- a/lib/widget/company/supplier_part_list.dart +++ b/lib/widget/company/supplier_part_list.dart @@ -57,13 +57,11 @@ class _PaginatedSupplierPartListState Map> get filterOptions { Map> filters = {}; - if (InvenTreeAPI().supportsCompanyActiveStatus) { - filters["active"] = { - "label": L10().filterActive, - "help_text": L10().filterActiveDetail, - "tristate": true, - }; - } + filters["active"] = { + "label": L10().filterActive, + "help_text": L10().filterActiveDetail, + "tristate": true, + }; if (InvenTreeAPI().supportsSupplierPartPrimaryField) { filters["primary"] = { diff --git a/lib/widget/order/purchase_order_detail.dart b/lib/widget/order/purchase_order_detail.dart index 41d589c1..e5c54d31 100644 --- a/lib/widget/order/purchase_order_detail.dart +++ b/lib/widget/order/purchase_order_detail.dart @@ -322,8 +322,7 @@ class _PurchaseOrderDetailState } }); - if (api.supportsPurchaseOrderDestination && - widget.order.destinationId > 0) { + if (widget.order.destinationId > 0) { InvenTreeStockLocation().get(widget.order.destinationId).then(( InvenTreeModel? loc, ) { @@ -593,19 +592,17 @@ class _PurchaseOrderDetailState tiles.add(parameterTile); } - ListTile? attachmentTile = ShowAttachmentsItem( - context, - InvenTreePurchaseOrder.MODEL_TYPE, - widget.order.pk, - widget.order.reference, - attachmentCount, - widget.order.canEdit, + tiles.add( + ShowAttachmentsItem( + context, + InvenTreePurchaseOrder.MODEL_TYPE, + widget.order.pk, + widget.order.reference, + attachmentCount, + widget.order.canEdit, + ), ); - if (attachmentTile != null) { - tiles.add(attachmentTile); - } - return tiles; } diff --git a/lib/widget/order/sales_order_detail.dart b/lib/widget/order/sales_order_detail.dart index 88ab0d97..3a1a42cf 100644 --- a/lib/widget/order/sales_order_detail.dart +++ b/lib/widget/order/sales_order_detail.dart @@ -518,19 +518,17 @@ class _SalesOrderDetailState extends RefreshableState { tiles.add(parameterTile); } - ListTile? attachmentTile = ShowAttachmentsItem( - context, - InvenTreeSalesOrder.MODEL_TYPE, - widget.order.pk, - widget.order.reference, - attachmentCount, - widget.order.canEdit, + tiles.add( + ShowAttachmentsItem( + context, + InvenTreeSalesOrder.MODEL_TYPE, + widget.order.pk, + widget.order.reference, + attachmentCount, + widget.order.canEdit, + ), ); - if (attachmentTile != null) { - tiles.add(attachmentTile); - } - return tiles; } diff --git a/lib/widget/order/so_shipment_detail.dart b/lib/widget/order/so_shipment_detail.dart index d7461ca8..03a60355 100644 --- a/lib/widget/order/so_shipment_detail.dart +++ b/lib/widget/order/so_shipment_detail.dart @@ -354,19 +354,17 @@ class _SOShipmentDetailWidgetState ); } - ListTile? attachmentTile = ShowAttachmentsItem( - context, - InvenTreeSalesOrderShipment.MODEL_TYPE, - widget.shipment.pk, - widget.shipment.reference, - attachmentCount, - widget.shipment.canEdit, + tiles.add( + ShowAttachmentsItem( + context, + InvenTreeSalesOrderShipment.MODEL_TYPE, + widget.shipment.pk, + widget.shipment.reference, + attachmentCount, + widget.shipment.canEdit, + ), ); - if (attachmentTile != null) { - tiles.add(attachmentTile); - } - return tiles; } diff --git a/lib/widget/part/category_display.dart b/lib/widget/part/category_display.dart index f13db527..25ca6ce4 100644 --- a/lib/widget/part/category_display.dart +++ b/lib/widget/part/category_display.dart @@ -1,7 +1,6 @@ import "package:flutter/material.dart"; import "package:flutter_speed_dial/flutter_speed_dial.dart"; import "package:flutter_tabler_icons/flutter_tabler_icons.dart"; -import "package:inventree/api.dart"; import "package:inventree/app_colors.dart"; import "package:inventree/l10.dart"; @@ -195,11 +194,7 @@ class _CategoryDisplayState extends RefreshableState { if (parent != null) { filters["parent"] = parent.toString(); } else { - if (InvenTreeAPI().supportsTopLevelFiltering) { - filters["top_level"] = "true"; - } else { - filters["parent"] = "null"; - } + filters["top_level"] = "true"; } List tiles = [ diff --git a/lib/widget/part/category_list.dart b/lib/widget/part/category_list.dart index 02228726..eb6b9ea1 100644 --- a/lib/widget/part/category_list.dart +++ b/lib/widget/part/category_list.dart @@ -6,7 +6,6 @@ import "package:inventree/widget/link_icon.dart"; import "package:inventree/widget/paginator.dart"; import "package:inventree/widget/refreshable_state.dart"; -import "package:inventree/api.dart"; import "package:inventree/l10.dart"; class PartCategoryList extends StatefulWidget { @@ -66,20 +65,12 @@ class _PaginatedPartCategoryListState @override Map get orderingOptions { - Map options = { + return { "name": L10().name, "pathstring": L10().path, "level": L10().level, + "part_count": L10().parts, }; - - // Note: API v69 changed 'parts' to 'part_count' - if (InvenTreeAPI().apiVersion >= 69) { - options["part_count"] = L10().parts; - } else { - options["parts"] = L10().parts; - } - - return options; } @override diff --git a/lib/widget/part/part_detail.dart b/lib/widget/part/part_detail.dart index c3274a97..c44bc066 100644 --- a/lib/widget/part/part_detail.dart +++ b/lib/widget/part/part_detail.dart @@ -124,7 +124,7 @@ class _PartDisplayState extends RefreshableState { ); } - if (allowLabelPrinting && api.supportsModernLabelPrinting) { + if (allowLabelPrinting) { actions.add( SpeedDialChild( child: Icon(TablerIcons.printer), @@ -221,17 +221,15 @@ class _PartDisplayState extends RefreshableState { } // Request the number of attachments - if (api.supportsModernAttachments) { - InvenTreeAttachment() - .countAttachments(InvenTreePart.MODEL_TYPE, part.pk) - .then((int value) { - if (mounted) { - setState(() { - attachmentCount = value; - }); - } - }); - } + InvenTreeAttachment() + .countAttachments(InvenTreePart.MODEL_TYPE, part.pk) + .then((int value) { + if (mounted) { + setState(() { + attachmentCount = value; + }); + } + }); // Request the number of parameters if (api.supportsModernParameters) { @@ -749,19 +747,17 @@ class _PartDisplayState extends RefreshableState { tiles.add(parameterTile); } - ListTile? attachmentTile = ShowAttachmentsItem( - context, - InvenTreePart.MODEL_TYPE, - part.pk, - L10().part, - attachmentCount, - part.canEdit, + tiles.add( + ShowAttachmentsItem( + context, + InvenTreePart.MODEL_TYPE, + part.pk, + L10().part, + attachmentCount, + part.canEdit, + ), ); - if (attachmentTile != null) { - tiles.add(attachmentTile); - } - return tiles; } diff --git a/lib/widget/stock/location_display.dart b/lib/widget/stock/location_display.dart index 1975a77b..71c43318 100644 --- a/lib/widget/stock/location_display.dart +++ b/lib/widget/stock/location_display.dart @@ -1,7 +1,6 @@ import "package:flutter/material.dart"; import "package:flutter_speed_dial/flutter_speed_dial.dart"; import "package:flutter_tabler_icons/flutter_tabler_icons.dart"; -import "package:inventree/api.dart"; import "package:inventree/app_colors.dart"; import "package:inventree/barcode/barcode.dart"; @@ -178,9 +177,7 @@ class _LocationDisplayState extends RefreshableState { ); } - if (widget.location != null && - allowLabelPrinting && - api.supportsModernLabelPrinting) { + if (widget.location != null && allowLabelPrinting) { actions.add( SpeedDialChild( child: Icon(TablerIcons.printer), @@ -361,11 +358,7 @@ class _LocationDisplayState extends RefreshableState { if (parent != null) { filters["parent"] = parent.toString(); } else { - if (InvenTreeAPI().supportsTopLevelFiltering) { - filters["top_level"] = "true"; - } else { - filters["parent"] = "null"; - } + filters["top_level"] = "true"; } List tiles = [ diff --git a/lib/widget/stock/stock_detail.dart b/lib/widget/stock/stock_detail.dart index 1dfb7e89..45e4335a 100644 --- a/lib/widget/stock/stock_detail.dart +++ b/lib/widget/stock/stock_detail.dart @@ -128,7 +128,7 @@ class _StockItemDisplayState extends RefreshableState { ); } - if (allowLabelPrinting && api.supportsModernLabelPrinting) { + if (allowLabelPrinting) { actions.add( SpeedDialChild( child: Icon(TablerIcons.printer), @@ -825,19 +825,17 @@ class _StockItemDisplayState extends RefreshableState { ); } - ListTile? attachmentTile = ShowAttachmentsItem( - context, - InvenTreeStockItem.MODEL_TYPE, - widget.item.pk, - L10().stockItem, - attachmentCount, - widget.item.canEdit, + tiles.add( + ShowAttachmentsItem( + context, + InvenTreeStockItem.MODEL_TYPE, + widget.item.pk, + L10().stockItem, + attachmentCount, + widget.item.canEdit, + ), ); - if (attachmentTile != null) { - tiles.add(attachmentTile); - } - return tiles; } } diff --git a/test/order_models_test.dart b/test/order_models_test.dart index 4173bc43..b8e6fb42 100644 --- a/test/order_models_test.dart +++ b/test/order_models_test.dart @@ -648,9 +648,6 @@ void main() { }); test("Company Form Fields", () async { - expect(InvenTreeCompany().formFields().containsKey("active"), isFalse); - - InvenTreeAPI().serverInfo = {"apiVersion": 189}; expect(InvenTreeCompany().formFields().containsKey("active"), isTrue); }); @@ -677,14 +674,16 @@ void main() { expect(sp.active, isTrue); expect(sp.primary, isFalse); - // Older API versions use "pack_size" - expect(sp.pack_quantity, equals("10")); - expect(sp.formFields().containsKey("pack_size"), isTrue); + expect(sp.pack_quantity, equals("1 reel")); + expect(sp.formFields().containsKey("pack_quantity"), isTrue); + expect(sp.formFields().containsKey("pack_size"), isFalse); + expect(sp.formFields().containsKey("active"), isTrue); + + // The "primary" field requires API v456 + InvenTreeAPI().serverInfo = {"apiVersion": 455}; expect(sp.formFields().containsKey("primary"), isFalse); InvenTreeAPI().serverInfo = {"apiVersion": 456}; - expect(sp.pack_quantity, equals("1 reel")); - expect(sp.formFields().containsKey("pack_quantity"), isTrue); expect(sp.formFields().containsKey("primary"), isTrue); // Missing images