@@ -287,65 +287,67 @@ class InvenTreeAPI {
287
287
int get apiVersion => (serverInfo["apiVersion" ] ?? 1 ) as int ;
288
288
289
289
// Consolidated search request API v102 or newer
290
- bool get supportsConsolidatedSearch => apiVersion >= 102 ;
290
+ bool get supportsConsolidatedSearch => apiVersion >= 102 ;
291
291
292
292
// ReturnOrder supports API v104 or newer
293
- bool get supportsReturnOrders => apiVersion >= 104 ;
293
+ bool get supportsReturnOrders => apiVersion >= 104 ;
294
294
295
295
// "Contact" model exposed to API
296
- bool get supportsContactModel => apiVersion >= 104 ;
296
+ bool get supportsContactModel => apiVersion >= 104 ;
297
297
298
298
// Status label endpoints API v105 or newer
299
- bool get supportsStatusLabelEndpoints => apiVersion >= 105 ;
299
+ bool get supportsStatusLabelEndpoints => apiVersion >= 105 ;
300
300
301
301
// Regex search API v106 or newer
302
- bool get supportsRegexSearch => apiVersion >= 106 ;
302
+ bool get supportsRegexSearch => apiVersion >= 106 ;
303
303
304
304
// Order barcodes API v107 or newer
305
- bool get supportsOrderBarcodes => apiVersion >= 107 ;
305
+ bool get supportsOrderBarcodes => apiVersion >= 107 ;
306
306
307
307
// Project codes require v109 or newer
308
- bool get supportsProjectCodes => apiVersion >= 109 ;
308
+ bool get supportsProjectCodes => apiVersion >= 109 ;
309
309
310
310
// Does the server support extra fields on stock adjustment actions?
311
- bool get supportsStockAdjustExtraFields => apiVersion >= 133 ;
311
+ bool get supportsStockAdjustExtraFields => apiVersion >= 133 ;
312
312
313
313
// Does the server support receiving items against a PO using barcodes?
314
- bool get supportsBarcodePOReceiveEndpoint => apiVersion >= 139 ;
314
+ bool get supportsBarcodePOReceiveEndpoint => apiVersion >= 139 ;
315
315
316
316
// Does the server support adding line items to a PO using barcodes?
317
- bool get supportsBarcodePOAddLineEndpoint => apiVersion >= 153 ;
317
+ bool get supportsBarcodePOAddLineEndpoint => apiVersion >= 153 ;
318
318
319
319
// Does the server support allocating stock to sales order using barcodes?
320
- bool get supportsBarcodeSOAllocateEndpoint => apiVersion >= 160 ;
320
+ bool get supportsBarcodeSOAllocateEndpoint => apiVersion >= 160 ;
321
321
322
322
// Does the server support the "modern" test results API
323
323
// Ref: https://github.com/inventree/InvenTree/pull/6430/
324
- bool get supportsModernTestResults => apiVersion >= 169 ;
324
+ bool get supportsModernTestResults => apiVersion >= 169 ;
325
325
326
326
// Does the server support "null" top-level filtering for PartCategory and StockLocation endpoints?
327
- bool get supportsNullTopLevelFiltering => apiVersion < 174 ;
327
+ bool get supportsNullTopLevelFiltering => apiVersion < 174 ;
328
328
329
329
// Does the server support "active" status on Company and SupplierPart API endpoints?
330
- bool get supportsCompanyActiveStatus => apiVersion >= 189 ;
330
+ bool get supportsCompanyActiveStatus => apiVersion >= 189 ;
331
331
332
332
// Does the server support the "modern" (consolidated) label printing API?
333
- bool get supportsModernLabelPrinting => apiVersion >= 201 ;
333
+ bool get supportsModernLabelPrinting => apiVersion >= 201 ;
334
334
335
335
// Does the server support the "modern" (consolidated) attachment API?
336
336
// Ref: https://github.com/inventree/InvenTree/pull/7420
337
- bool get supportsModernAttachments => apiVersion >= 207 ;
337
+ bool get supportsModernAttachments => apiVersion >= 207 ;
338
+
339
+ bool get supportsUserPermissions => apiVersion >= 207 ;
338
340
339
341
// Does the server support the "destination" field on the PurchaseOrder model?
340
342
// Ref: https://github.com/inventree/InvenTree/pull/8403
341
- bool get supportsPurchaseOrderDestination => apiVersion >= 276 ;
343
+ bool get supportsPurchaseOrderDestination => apiVersion >= 276 ;
342
344
343
345
// Does the server support the "start_date" field for orders?
344
346
// Ref: https://github.com/inventree/InvenTree/pull/8966
345
- bool get supportsStartDate => apiVersion >= 306 ;
347
+ bool get supportsStartDate => apiVersion >= 306 ;
346
348
347
349
// Supports separate search against "supplier" / "customer" / "manufacturer"
348
- bool get supportsSplitCompanySearch => apiVersion >= 315 ;
350
+ bool get supportsSplitCompanySearch => apiVersion >= 315 ;
349
351
350
352
// Cached list of plugins (refreshed when we connect to the server)
351
353
List <InvenTreePlugin > _plugins = [];
@@ -725,7 +727,12 @@ class InvenTreeAPI {
725
727
}
726
728
727
729
roles = (data["roles" ] ?? {}) as Map <String , dynamic >;
728
- permissions = (data["permissions" ] ?? {}) as Map <String , dynamic >;
730
+
731
+ if (supportsUserPermissions && data.containsKey ("permissions" )) {
732
+ permissions = (data["permissions" ] ?? {}) as Map <String , dynamic >;
733
+ } else {
734
+ permissions = {};
735
+ }
729
736
730
737
return true ;
731
738
}
@@ -1194,6 +1201,15 @@ class InvenTreeAPI {
1194
1201
1195
1202
var _url = makeApiUrl (url);
1196
1203
1204
+ if (_url.isEmpty) {
1205
+ showServerError (
1206
+ url,
1207
+ L10 ().invalidHost,
1208
+ L10 ().invalidHostDetails
1209
+ );
1210
+ return null ;
1211
+ }
1212
+
1197
1213
// Add any required query parameters to the URL using ?key=value notation
1198
1214
if (urlParams.isNotEmpty) {
1199
1215
String query = "?" ;
@@ -1210,13 +1226,12 @@ class InvenTreeAPI {
1210
1226
1211
1227
Uri ? _uri = Uri .tryParse (_url);
1212
1228
1213
- if (_uri == null ) {
1214
- showServerError (url, L10 ().invalidHost, L10 ().invalidHostDetails);
1215
- return null ;
1216
- }
1217
-
1218
- if (_uri.host.isEmpty) {
1219
- showServerError (url, L10 ().invalidHost, L10 ().invalidHostDetails);
1229
+ if (_uri == null || _uri.host.isEmpty) {
1230
+ showServerError (
1231
+ _url,
1232
+ L10 ().invalidHost,
1233
+ L10 ().invalidHostDetails
1234
+ );
1220
1235
return null ;
1221
1236
}
1222
1237
0 commit comments