From dd12769a5139a981a0f72a1d1ace61dfbdef4a61 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 9 Sep 2023 00:32:57 +1000 Subject: [PATCH] Stock transfer extra (#420) * Add API version check * Support "packaging" and "status" fields when performing a stock-transfer action * Update release notes --- assets/release_notes.md | 5 +++++ lib/api.dart | 3 +++ lib/widget/stock_detail.dart | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/assets/release_notes.md b/assets/release_notes.md index 737cb5ad..dd851dce 100644 --- a/assets/release_notes.md +++ b/assets/release_notes.md @@ -1,3 +1,8 @@ +### 0.12.8 - September 2023 +--- + +- Added extra options for transferring stock items + ### 0.12.7 - August 2023 --- diff --git a/lib/api.dart b/lib/api.dart index fa740e06..b8a4f21f 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -323,6 +323,9 @@ class InvenTreeAPI { // Project codes require v109 or newer bool get supportsProjectCodes => isConnected() && apiVersion >= 109; + // Does the server support extra fields on stock adjustment actions? + bool get supportsStockAdjustExtraFields => isConnected() && apiVersion >= 133; + // Are plugins enabled on the server? bool _pluginsEnabled = false; diff --git a/lib/widget/stock_detail.dart b/lib/widget/stock_detail.dart index decf402a..b917e01a 100644 --- a/lib/widget/stock_detail.dart +++ b/lib/widget/stock_detail.dart @@ -451,6 +451,16 @@ class _StockItemDisplayState extends RefreshableState { "location": { "value": widget.item.locationId, }, + "status": { + "parent": "items", + "nested": true, + "value": widget.item.status, + }, + "packaging": { + "parent": "items", + "nested": true, + "value": widget.item.packaging, + }, "notes": {}, }; @@ -459,6 +469,12 @@ class _StockItemDisplayState extends RefreshableState { fields["quantity"]["hidden"] = true; } + // Old API does not support these fields + if (!api.supportsStockAdjustExtraFields) { + fields.remove("packaging"); + fields.remove("status"); + } + launchApiForm( context, L10().transferStock,