diff --git a/assets/release_notes.md b/assets/release_notes.md index 2027c936..72324c15 100644 --- a/assets/release_notes.md +++ b/assets/release_notes.md @@ -1,6 +1,7 @@ ### x.xx.x - Month Year --- +- Support display of custom status codes - Fix default values for list sorting diff --git a/lib/inventree/model.dart b/lib/inventree/model.dart index 25c17084..3a39e64f 100644 --- a/lib/inventree/model.dart +++ b/lib/inventree/model.dart @@ -334,6 +334,24 @@ class InvenTreeModel { String get description => getString("description"); + int get logicalStatus => getInt("status"); + + int get customStatus => getInt("status_custom_key"); + + // Return the effective status of this object + // If a custom status is defined, return that, otherwise return the logical status + int get status { + if (customStatus > 0) { + return customStatus; + } else { + return logicalStatus; + } + } + + String get statusText => getString("status_text"); + + bool get hasCustomStatus => customStatus > 0 && customStatus != status; + String get notes => getString("notes"); int get parentId => getInt("parent"); diff --git a/lib/inventree/orders.dart b/lib/inventree/orders.dart index 8ffc4782..124ded2a 100644 --- a/lib/inventree/orders.dart +++ b/lib/inventree/orders.dart @@ -57,10 +57,6 @@ class InvenTreeOrder extends InvenTreeModel { bool get hasProjectCode => projectCode.isNotEmpty; - int get status => getInt("status"); - - String get statusText => getString("status_text"); - double? get totalPrice { String price = getString("total_price"); diff --git a/lib/inventree/stock.dart b/lib/inventree/stock.dart index 4b5bf3b0..657a2181 100644 --- a/lib/inventree/stock.dart +++ b/lib/inventree/stock.dart @@ -256,8 +256,6 @@ class InvenTreeStockItem extends InvenTreeModel { }); } - int get status => getInt("status"); - bool get isInStock => getBool("in_stock", backup: true); String get packaging => getString("packaging");