From 08e01a729bc5c08b45d3cdd2fae3867a5dac409e Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 11 Dec 2024 15:48:24 +1100 Subject: [PATCH] Updates (cherry picked from commit 94125667d9cdd1bd486aa58a2c4908c143b47225) --- assets/release_notes.md | 1 + lib/api.dart | 4 ++++ lib/inventree/purchase_order.dart | 7 +++++++ lib/l10n/app_en.arb | 3 +++ 4 files changed, 15 insertions(+) diff --git a/assets/release_notes.md b/assets/release_notes.md index e4367d53..c72bd2c1 100644 --- a/assets/release_notes.md +++ b/assets/release_notes.md @@ -2,6 +2,7 @@ --- - Fixes barcode scanning bug which prevents scanning of DataMatrix codes +- Display "destination" information in PurchaseOrder detail view - Adds "assigned to me" filter for Purchase Order list - Adds "assigned to me" filter for Sales Order list diff --git a/lib/api.dart b/lib/api.dart index 704b7df1..d686e1b1 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -333,6 +333,10 @@ class InvenTreeAPI { // Ref: https://github.com/inventree/InvenTree/pull/7420 bool get supportsModernAttachments => isConnected() && apiVersion >= 207; + // Does the server support the "destination" field on the PurchaseOrder model? + // Ref: https://github.com/inventree/InvenTree/pull/8403 + bool get supportsPurchaseOrderDestination => isConnected() && apiVersion >= 276; + // Cached list of plugins (refreshed when we connect to the server) List _plugins = []; diff --git a/lib/inventree/purchase_order.dart b/lib/inventree/purchase_order.dart index e4723881..9a4f4943 100644 --- a/lib/inventree/purchase_order.dart +++ b/lib/inventree/purchase_order.dart @@ -40,6 +40,7 @@ class InvenTreePurchaseOrder extends InvenTreeOrder { "supplier_reference": {}, "description": {}, "project_code": {}, + "destination": {}, "target_date": {}, "link": {}, "responsible": {}, @@ -54,6 +55,10 @@ class InvenTreePurchaseOrder extends InvenTreeOrder { fields.remove("project_code"); } + if (!InvenTreeAPI().supportsPurchaseOrderDestination) { + fields.remove("destination"); + } + return fields; } @@ -87,6 +92,8 @@ class InvenTreePurchaseOrder extends InvenTreeOrder { String get supplierReference => getString("supplier_reference"); + int get destinationId => getInt("destination"); + bool get isOpen => api.PurchaseOrderStatus.isNameIn(status, ["PENDING", "PLACED", "ON_HOLD"]); bool get isPending => api.PurchaseOrderStatus.isNameIn(status, ["PENDING", "ON_HOLD"]); diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 3ce98666..72d5d92f 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -310,6 +310,9 @@ "description": "Description", "@description": {}, + "destination": "Destination", + "@destination": {}, + "destroyed": "Destroyed", "@destroyed": {},