2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-15 11:45:31 +00:00

Major refactoring for model data accessors

This commit is contained in:
Oliver Walters
2023-04-21 20:25:29 +10:00
parent bfb582efb2
commit bff2a5e2a9
7 changed files with 188 additions and 227 deletions

View File

@ -36,13 +36,13 @@ class InvenTreeBomItem extends InvenTreeModel {
}
// Extract the 'reference' value associated with this BomItem
String get reference => (jsondata["reference"] ?? "") as String;
String get reference => getString("reference");
// Extract the 'quantity' value associated with this BomItem
double get quantity => double.tryParse(jsondata["quantity"].toString()) ?? 0;
double get quantity => getDouble("quantity");
// Extract the ID of the related part
int get partId => int.tryParse(jsondata["part"].toString()) ?? -1;
int get partId => getInt("part");
// Return a Part instance for the referenced part
InvenTreePart? get part {
@ -69,5 +69,5 @@ class InvenTreeBomItem extends InvenTreeModel {
}
// Extract the ID of the related sub-part
int get subPartId => int.tryParse(jsondata["sub_part"].toString()) ?? -1;
int get subPartId => getInt("sub_part");
}

View File

@ -38,22 +38,22 @@ class InvenTreeCompany extends InvenTreeModel {
String get thumbnail => (jsondata["thumbnail"] ?? jsondata["image"] ?? InvenTreeAPI.staticThumb) as String;
String get website => (jsondata["website"] ?? "") as String;
String get website => getString("website");
String get phone => getString("phone");
String get phone => (jsondata["phone"] ?? "") as String;
String get email => getString("email");
String get email => (jsondata["email"] ?? "") as String;
bool get isSupplier => getBool("is_supplier");
bool get isSupplier => (jsondata["is_supplier"] ?? false) as bool;
bool get isManufacturer => getBool("is_manufacturer");
bool get isManufacturer => (jsondata["is_manufacturer"] ?? false) as bool;
bool get isCustomer => (jsondata["is_customer"] ?? false) as bool;
int get partSuppliedCount => (jsondata["parts_supplied"] ?? 0) as int;
int get partManufacturedCount => (jsondata["parts_manufactured"] ?? 0) as int;
bool get isCustomer => getBool("is_customer");
int get partSuppliedCount => getInt("part_supplied");
int get partManufacturedCount => getInt("parts_manufactured");
// Request a list of purchase orders against this company
Future<List<InvenTreePurchaseOrder>> getPurchaseOrders({bool? outstanding}) async {
@ -154,33 +154,33 @@ class InvenTreeSupplierPart extends InvenTreeModel {
return _filters();
}
int get manufacturerId => (jsondata["manufacturer_detail"]["pk"] ?? -1) as int;
String get manufacturerName => (jsondata["manufacturer_detail"]?["name"] ?? "") as String;
String get MPN => (jsondata["manufacturer_part_detail"]?["MPN"] ?? "") as String;
int get manufacturerId => getInt("pk", subKey: "manufacturer_detail");
String get manufacturerName => getString("name", subKey: "manufacturer_detail");
String get MPN => getString("MPN", subKey: "manufacturer_part_detail");
String get manufacturerImage => (jsondata["manufacturer_detail"]?["image"] ?? jsondata["manufacturer_detail"]["thumbnail"] ?? InvenTreeAPI.staticThumb) as String;
int get manufacturerPartId => (jsondata["manufacturer_part"] ?? -1) as int;
int get supplierId => (jsondata["supplier"] ?? -1) as int;
String get supplierName => (jsondata["supplier_detail"]?["name"] ?? "") as String;
int get manufacturerPartId => getInt("manufacturer_part");
int get supplierId => getInt("supplier");
String get supplierName => getString("name", subKey: "supplier_detail");
String get supplierImage => (jsondata["supplier_detail"]?["image"] ?? jsondata["supplier_detail"]["thumbnail"] ?? InvenTreeAPI.staticThumb) as String;
String get SKU => (jsondata["SKU"] ?? "") as String;
int get partId => (jsondata["part"] ?? -1) as int;
String get SKU => getString("SKU");
int get partId => getInt("part");
String get partImage => (jsondata["part_detail"]?["thumbnail"] ?? InvenTreeAPI.staticThumb) as String;
String get partName => (jsondata["part_detail"]?["full_name"] ?? "") as String;
String get partDescription => (jsondata["part_detail"]?["description"] ?? "") as String;
String get note => (jsondata["note"] ?? "") as String;
String get partName => getString("full_name", subKey: "part_detail");
String get partDescription => getString("description", subKey: "part_detail");
String get note => getString("note");
@override
InvenTreeModel createFromJson(Map<String, dynamic> json) {
@ -207,12 +207,12 @@ class InvenTreeManufacturerPart extends InvenTreeModel {
};
}
int get partId => (jsondata["part"] ?? -1) as int;
int get manufacturerId => (jsondata["manufacturer"] ?? -1) as int;
String get MPN => (jsondata["MPN"] ?? "") as String;
int get partId => getInt("part");
int get manufacturerId => getInt("manufacturer");
String get MPN => getString("MPN");
@override
InvenTreeModel createFromJson(Map<String, dynamic> json) {
var part = InvenTreeManufacturerPart.fromJson(json);

View File

@ -252,16 +252,16 @@ class InvenTreeModel {
// Accessor for the API
InvenTreeAPI get api => InvenTreeAPI();
int get pk => (jsondata["pk"] ?? -1) as int;
int get pk => getInt("pk");
// Some common accessors
String get name => (jsondata["name"] ?? "") as String;
String get name => getString("name");
String get description => (jsondata["description"] ?? "") as String;
String get description => getString("description");
String get notes => getString("notes");
String get notes => (jsondata["notes"] ?? "") as String;
int get parentId => (jsondata["parent"] ?? -1) as int;
int get parentId => getInt("parent");
// Legacy API provided external link as "URL", while newer API uses "link"
String get link => (jsondata["link"] ?? jsondata["URL"] ?? "") as String;
@ -358,8 +358,8 @@ class InvenTreeModel {
}
}
String get keywords => (jsondata["keywords"] ?? "") as String;
String get keywords => getString("keywords");
// Create a new object from JSON data (not a constructor!)
InvenTreeModel createFromJson(Map<String, dynamic> json) {
@ -826,10 +826,10 @@ class InvenTreePlugin extends InvenTreeModel {
}
}
String get key => (jsondata["key"] ?? "") as String;
bool get active => (jsondata["active"] ?? false) as bool;
String get key => getString("key");
bool get active => getBool("active");
// Return the metadata struct for this plugin
Map<String, dynamic> get _meta => (jsondata["meta"] ?? {}) as Map<String, dynamic>;
@ -864,11 +864,11 @@ class InvenTreeGlobalSetting extends InvenTreeModel {
@override
String get URL => "settings/global/";
String get key => (jsondata["key"] ?? "") as String;
String get value => (jsondata["value"] ?? "") as String;
String get type => (jsondata["type"] ?? "") as String;
String get key => getString("key");
String get value => getString("value");
String get type => getString("type");
}
@ -897,8 +897,8 @@ class InvenTreeAttachment extends InvenTreeModel {
// Override this reference field for any subclasses
String get REFERENCE_FIELD => "";
String get attachment => (jsondata["attachment"] ?? "") as String;
String get attachment => getString("attachment");
// Return the filename of the attachment
String get filename {
return attachment.split("/").last;
@ -935,8 +935,8 @@ class InvenTreeAttachment extends InvenTreeModel {
return FontAwesomeIcons.fileLines;
}
String get comment => (jsondata["comment"] ?? "") as String;
String get comment => getString("comment");
DateTime? get uploadDate {
if (jsondata.containsKey("upload_date")) {
return DateTime.tryParse((jsondata["upload_date"] ?? "") as String);

View File

@ -27,8 +27,8 @@ class InvenTreeNotification extends InvenTreeModel {
};
}
String get message => (jsondata["message"] ?? "") as String;
String get message => getString("message");
DateTime? get creationDate {
if (jsondata.containsKey("creation")) {
return DateTime.tryParse((jsondata["creation"] ?? "") as String);

View File

@ -43,8 +43,8 @@ class InvenTreePartCategory extends InvenTreeModel {
return fields;
}
String get pathstring => (jsondata["pathstring"] ?? "") as String;
String get pathstring => getString("pathstring");
String get parentPathString {
List<String> psplit = pathstring.split("/");
@ -87,15 +87,15 @@ class InvenTreePartTestTemplate extends InvenTreeModel {
@override
String get URL => "part/test-template/";
String get key => (jsondata["key"] ?? "") as String;
String get key => getString("key");
String get testName => (jsondata["test_name"] ?? "") as String;
String get testName => getString("test_name");
bool get required => (jsondata["required"] ?? false) as bool;
bool get required => getBool("required");
bool get requiresValue => getBool("requires_value");
bool get requiresValue => (jsondata["requires_value"] ?? false) as bool;
bool get requiresAttachment => (jsondata["requires_attachment"] ?? false) as bool;
bool get requiresAttachment => getBool("requires_attachment");
@override
InvenTreeModel createFromJson(Map<String, dynamic> json) {
@ -152,13 +152,13 @@ class InvenTreePartParameter extends InvenTreeModel {
}
@override
String get name => (jsondata["template_detail"]?["name"] ?? "") as String;
String get name => getString("name", subKey: "template_detail");
@override
String get description => (jsondata["template_detail"]?["description"] ?? "") as String;
String get value => jsondata["data"] as String;
String get description => getString("description", subKey: "template_detail");
String get value => getString("data");
String get valueString {
String v = value;
@ -170,7 +170,7 @@ class InvenTreePartParameter extends InvenTreeModel {
return v;
}
String get units => (jsondata["template_detail"]?["units"] ?? "") as String;
String get units => getString("units", subKey: "template_detail");
}
/*
@ -254,8 +254,8 @@ class InvenTreePart extends InvenTreeModel {
});
}
int get supplierCount => (jsondata["suppliers"] ?? 0) as int;
int get supplierCount => getInt("suppliers", backup: 0);
// Request supplier parts for this part
Future<List<InvenTreeSupplierPart>> getSupplierParts() async {
List<InvenTreeSupplierPart> _supplierParts = [];
@ -301,40 +301,26 @@ class InvenTreePart extends InvenTreeModel {
int? get defaultLocation => jsondata["default_location"] as int?;
// Get the number of stock on order for this Part
double get onOrder => double.tryParse(jsondata["ordering"].toString()) ?? 0;
double get onOrder => getDouble("ordering");
String get onOrderString {
String get onOrderString => simpleNumberString(onOrder);
return simpleNumberString(onOrder);
double get inStock => getDouble("in_stock");
String get inStockString => simpleNumberString(inStock);
// Get the 'available stock' for this Part
double get unallocatedStock {
// Note that the 'available_stock' was not added until API v35
if (jsondata.containsKey("unallocated_stock")) {
return double.tryParse(jsondata["unallocated_stock"].toString()) ?? 0;
} else {
return inStock;
}
}
// Get the stock count for this Part
double get inStock => double.tryParse(jsondata["in_stock"].toString()) ?? 0;
String get inStockString {
String q = simpleNumberString(inStock);
return q;
}
// Get the 'available stock' for this Part
double get unallocatedStock {
// Note that the 'available_stock' was not added until API v35
if (jsondata.containsKey("unallocated_stock")) {
return double.tryParse(jsondata["unallocated_stock"].toString()) ?? 0;
} else {
return inStock;
}
}
String get unallocatedStockString {
String q = simpleNumberString(unallocatedStock);
return q;
}
String get unallocatedStockString => simpleNumberString(unallocatedStock);
String stockString({bool includeUnits = true}) {
String q = unallocatedStockString;
@ -350,39 +336,39 @@ class InvenTreePart extends InvenTreeModel {
return q;
}
String get units => (jsondata["units"] ?? "") as String;
String get units => getString("units");
// Get the ID of the Part that this part is a variant of (or null)
int? get variantOf => jsondata["variant_of"] as int?;
// Get the number of units being build for this Part
double get building => double.tryParse(jsondata["building"].toString()) ?? 0;
double get building => getDouble("building");
// Get the number of BOMs this Part is used in (if it is a component)
int get usedInCount => (jsondata["used_in"] ?? 0) as int;
int get usedInCount => getInt("used_in");
bool get isAssembly => (jsondata["assembly"] ?? false) as bool;
bool get isAssembly => getBool("assembly");
bool get isComponent => (jsondata["component"] ?? false) as bool;
bool get isComponent => getBool("component");
bool get isPurchaseable => (jsondata["purchaseable"] ?? false) as bool;
bool get isPurchaseable => getBool("purchaseable");
bool get isSalable => (jsondata["salable"] ?? false) as bool;
bool get isSalable => getBool("salable");
bool get isActive => (jsondata["active"] ?? false) as bool;
bool get isActive => getBool("active");
bool get isVirtual => (jsondata["virtual"] ?? false) as bool;
bool get isVirtual => getBool("virtual");
bool get isTrackable => (jsondata["trackable"] ?? false) as bool;
bool get isTrackable => getBool("trackable");
// Get the IPN (internal part number) for the Part instance
String get IPN => (jsondata["IPN"] ?? "") as String;
String get IPN => getString("IPN");
// Get the revision string for the Part instance
String get revision => (jsondata["revision"] ?? "") as String;
String get revision => getString("revision");
// Get the category ID for the Part instance (or "null" if does not exist)
int get categoryId => (jsondata["category"] ?? -1) as int;
int get categoryId => getInt("category");
// Get the category name for the Part instance
String get categoryName {
@ -404,15 +390,15 @@ class InvenTreePart extends InvenTreeModel {
return (jsondata["category_detail"]?["description"] ?? "") as String;
}
// Get the image URL for the Part instance
String get _image => (jsondata["image"] ?? "") as String;
String get _image => getString("image");
// Get the thumbnail URL for the Part instance
String get _thumbnail => (jsondata["thumbnail"] ?? "") as String;
String get _thumbnail => getString("thumbnail");
// Return the fully-qualified name for the Part instance
String get fullname {
String fn = (jsondata["full_name"] ?? "") as String;
String fn = getString("full_name");
if (fn.isNotEmpty) return fn;
@ -456,7 +442,7 @@ class InvenTreePart extends InvenTreeModel {
}
// Return the "starred" status of this part
bool get starred => (jsondata["starred"] ?? false) as bool;
bool get starred => getBool("starred");
@override
InvenTreeModel createFromJson(Map<String, dynamic> json) {

View File

@ -59,23 +59,23 @@ class InvenTreePurchaseOrder extends InvenTreeModel {
};
}
String get issueDate => (jsondata["issue_date"] ?? "") as String;
String get issueDate => getString("issue_date");
String get completeDate => (jsondata["complete_date"] ?? "") as String;
String get completeDate => getString("complete_date");
String get creationDate => (jsondata["creation_date"] ?? "") as String;
String get creationDate => getString("creation_date");
String get targetDate => (jsondata["target_date"] ?? "") as String;
String get targetDate => getString("target_date");
int get lineItemCount => (jsondata["line_items"] ?? 0) as int;
int get lineItemCount => getInt("line_items", backup: 0);
bool get overdue => getBool("overdue");
bool get overdue => (jsondata["overdue"] ?? false) as bool;
String get reference => getString("reference");
String get reference => (jsondata["reference"] ?? "") as String;
int get responsibleId => getInt("responsible");
int get responsibleId => (jsondata["responsible"] ?? -1) as int;
int get supplierId => (jsondata["supplier"] ?? -1) as int;
int get supplierId => getInt("supplier");
InvenTreeCompany? get supplier {
@ -88,11 +88,11 @@ class InvenTreePurchaseOrder extends InvenTreeModel {
}
}
String get supplierReference => (jsondata["supplier_reference"] ?? "") as String;
String get supplierReference => getString("supplier_reference");
int get status => (jsondata["status"] ?? -1) as int;
int get status => getInt("status");
String get statusText => (jsondata["status_text"] ?? "") as String;
String get statusText => getString("status_text");
bool get isOpen => status == PO_STATUS_PENDING || status == PO_STATUS_PLACED;
@ -103,7 +103,7 @@ class InvenTreePurchaseOrder extends InvenTreeModel {
bool get isFailed => status == PO_STATUS_CANCELLED || status == PO_STATUS_LOST || status == PO_STATUS_RETURNED;
double? get totalPrice {
String price = (jsondata["total_price"] ?? "") as String;
String price = getString("total_price");
if (price.isEmpty) {
return null;
@ -112,7 +112,7 @@ class InvenTreePurchaseOrder extends InvenTreeModel {
}
}
String get totalPriceCurrency => (jsondata["total_price_currency"] ?? "") as String;
String get totalPriceCurrency => getString("total_price_currency");
Future<List<InvenTreePOLineItem>> getLineItems() async {
@ -199,17 +199,17 @@ class InvenTreePOLineItem extends InvenTreeModel {
bool get isComplete => received >= quantity;
double get quantity => (jsondata["quantity"] ?? 0) as double;
double get quantity => getDouble("quantity");
double get received => (jsondata["received"] ?? 0) as double;
double get received => getDouble("received");
double get outstanding => quantity - received;
String get reference => (jsondata["reference"] ?? "") as String;
String get reference => getString("reference");
int get orderId => (jsondata["order"] ?? -1) as int;
int get orderId => getInt("order");
int get supplierPartId => (jsondata["part"] ?? -1) as int;
int get supplierPartId => getInt("part");
InvenTreePart? get part {
dynamic part_detail = jsondata["part_detail"];
@ -232,16 +232,16 @@ class InvenTreePOLineItem extends InvenTreeModel {
}
}
double get purchasePrice => double.parse((jsondata["purchase_price"] ?? "") as String);
double get purchasePrice => getDouble("purchase_price");
String get purchasePriceCurrency => getString("purchase_price_currency");
String get purchasePriceCurrency => (jsondata["purchase_price_currency"] ?? "") as String;
String get purchasePriceString => getString("purchase_price_string");
String get purchasePriceString => (jsondata["purchase_price_string"] ?? "") as String;
int get destination => (jsondata["destination"] ?? -1) as int;
Map<String, dynamic> get destinationDetail => (jsondata["destination_detail"] ?? {}) as Map<String, dynamic>;
int get destination => getInt("destination");
Map<String, dynamic> get destinationDetail => getMap("destination_detail");
@override
InvenTreeModel createFromJson(Map<String, dynamic> json) {
return InvenTreePOLineItem.fromJson(json);

View File

@ -35,18 +35,18 @@ class InvenTreeStockItemTestResult extends InvenTreeModel {
};
}
String get key => (jsondata["key"] ?? "") as String;
String get testName => (jsondata["test"] ?? "") as String;
bool get result => (jsondata["result"] ?? false) as bool;
String get value => (jsondata["value"] ?? "") as String;
String get attachment => (jsondata["attachment"] ?? "") as String;
String get date => (jsondata["date"] ?? "") as String;
String get key => getString("key");
String get testName => getString("test");
bool get result => getBool("result");
String get value => getString("value");
String get attachment => getString("attachment");
String get date => getString("date");
@override
InvenTreeStockItemTestResult createFromJson(Map<String, dynamic> json) {
var result = InvenTreeStockItemTestResult.fromJson(json);
@ -98,16 +98,10 @@ class InvenTreeStockItemHistory extends InvenTreeModel {
return DateFormat("yyyy-MM-dd").format(d);
}
String get label => (jsondata["label"] ?? "") as String;
String get label => getString("label");
// Return the "deltas" associated with this historical object
Map<String, dynamic> get deltas {
if (jsondata.containsKey("deltas")) {
return jsondata["deltas"] as Map<String, dynamic>;
} else {
return {};
}
}
Map<String, dynamic> get deltas => getMap("deltas");
// Return the quantity string for this historical object
String get quantityString {
@ -122,12 +116,13 @@ class InvenTreeStockItemHistory extends InvenTreeModel {
}
}
String get userString {
return (jsondata["user_detail"]?["username"] ?? "") as String;
}
String get userString => getString("username", subKey: "user_detail");
}
/*
* Class representing a StockItem database instance
*/
class InvenTreeStockItem extends InvenTreeModel {
InvenTreeStockItem() : super();
@ -237,16 +232,16 @@ class InvenTreeStockItem extends InvenTreeModel {
});
}
int get status => (jsondata["status"] ?? -1) as int;
int get status => getInt("staus");
String get packaging => getString("packaging");
String get packaging => (jsondata["packaging"] ?? "") as String;
String get batch => getString("batch");
String get batch => (jsondata["batch"] ?? "") as String;
int get partId => (jsondata["part"] ?? -1) as int;
int get partId => getInt("part");
double? get purchasePrice {
String pp = (jsondata["purchase_price"] ?? "") as String;
String pp = getString("purchase_price");
if (pp.isEmpty) {
return null;
@ -255,18 +250,18 @@ class InvenTreeStockItem extends InvenTreeModel {
}
}
String get purchasePriceCurrency => (jsondata["purchase_price_currency"] ?? "") as String;
String get purchasePriceCurrency => getString("purchase_price_currency");
bool get hasPurchasePrice {
double? pp = purchasePrice;
return pp != null && pp > 0;
}
int get purchaseOrderId => (jsondata["purchase_order"] ?? -1) as int;
int get purchaseOrderId => getInt("purchase_order");
int get trackingItemCount => (jsondata["tracking_items"] ?? 0) as int;
bool get isBuilding => (jsondata["is_building"] ?? false) as bool;
int get trackingItemCount => getInt("tracking_items", backup: 0);
bool get isBuilding => getBool("is_building");
// Date of last update
DateTime? get updatedDate {
@ -320,7 +315,7 @@ class InvenTreeStockItem extends InvenTreeModel {
// Backup if first value fails
if (nm.isEmpty) {
nm = (jsondata["part__name"] ?? "") as String;
nm = getString("part__name");
}
return nm;
@ -335,7 +330,7 @@ class InvenTreeStockItem extends InvenTreeModel {
}
if (desc.isEmpty) {
desc = (jsondata["part__description"] ?? "") as String;
desc = getString("part__description");
}
return desc;
@ -349,7 +344,7 @@ class InvenTreeStockItem extends InvenTreeModel {
}
if (img.isEmpty) {
img = (jsondata["part__thumbnail"] ?? "") as String;
img = getString("part__thumbnail");
}
return img;
@ -371,7 +366,7 @@ class InvenTreeStockItem extends InvenTreeModel {
// Try a different approach
if (thumb.isEmpty) {
thumb = (jsondata["part__thumbnail"] ?? "") as String;
thumb = getString("part__thumbnail");
}
// Still no thumbnail? Use the "no image" image
@ -380,7 +375,7 @@ class InvenTreeStockItem extends InvenTreeModel {
return thumb;
}
int get supplierPartId => (jsondata["supplier_part"] ?? -1) as int;
int get supplierPartId => getInt("supplier_part");
String get supplierImage {
String thumb = "";
@ -394,33 +389,15 @@ class InvenTreeStockItem extends InvenTreeModel {
return thumb;
}
String get supplierName {
String sname = "";
String get supplierName => getString("supplier_name", subKey: "supplier_detail");
if (jsondata.containsKey("supplier_detail")) {
sname = (jsondata["supplier_detail"]["supplier_name"] ?? "") as String;
}
String get units => getString("units", subKey: "part_detail");
return sname;
}
String get supplierSKU => getString("SKU", subKey: "supplier_part_detail");
String get units {
return (jsondata["part_detail"]?["units"] ?? "") as String;
}
String get serialNumber => getString("serial");
String get supplierSKU {
String sku = "";
if (jsondata.containsKey("supplier_part_detail")) {
sku = (jsondata["supplier_part_detail"]["SKU"] ?? "") as String;
}
return sku;
}
String get serialNumber => (jsondata["serial"] ?? "") as String;
double get quantity => double.tryParse(jsondata["quantity"].toString()) ?? 0;
double get quantity => getDouble("quantity");
String quantityString({bool includeUnits = false}){
@ -440,11 +417,11 @@ class InvenTreeStockItem extends InvenTreeModel {
return q;
}
double get allocated => double.tryParse(jsondata["allocated"].toString()) ?? 0;
double get allocated => getDouble("allocated");
double get available => quantity - allocated;
int get locationId => (jsondata["location"] ?? -1) as int;
int get locationId => getInt("location");
bool isSerialized() => serialNumber.isNotEmpty && quantity.toInt() == 1;
@ -459,15 +436,14 @@ class InvenTreeStockItem extends InvenTreeModel {
}
String get locationName {
String loc = "";
if (locationId == -1 || !jsondata.containsKey("location_detail")) return "Unknown Location";
loc = (jsondata["location_detail"]["name"] ?? "") as String;
String loc = getString("name", subKey: "location_detail");
// Old-style name
if (loc.isEmpty) {
loc = (jsondata["location__name"] ?? "") as String;
loc = getString("location__name");
}
return loc;
@ -477,8 +453,7 @@ class InvenTreeStockItem extends InvenTreeModel {
if (locationId == -1 || !jsondata.containsKey("location_detail")) return L10().locationNotSet;
String _loc = (jsondata["location_detail"]["pathstring"] ?? "") as String;
String _loc = getString("pathstring", subKey: "location_detail");
if (_loc.isNotEmpty) {
return _loc;
} else {
@ -620,7 +595,7 @@ class InvenTreeStockLocation extends InvenTreeModel {
@override
List<String> get rolesRequired => ["stock_location"];
String get pathstring => (jsondata["pathstring"] ?? "") as String;
String get pathstring => getString("pathstring");
@override
Map<String, dynamic> formFields() {