2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-13 10:45:29 +00:00

New barcode actions (#218)

* Bump release notes

* Adds method for linking custom barcodes

* Custom getter method for determining if an item has barcode data

* Add method to check if the API supports "modern" barcodes

* Refactor custom barcode implementation for StockItem

- Needs testing

* Unit testing for linking and unlinking barcodes

* Fixes

* Refactor code for "custom barcode action" tile

* Add custom barcode action to StockLocation

* Add extra debug to debug the debugging

* Unit test fix

* Change scope I guess?

* remove handler test
This commit is contained in:
Oliver
2022-12-05 23:39:40 +11:00
committed by GitHub
parent efb6fc353e
commit 730521fd00
11 changed files with 162 additions and 134 deletions

View File

@ -259,6 +259,9 @@ class InvenTreeAPI {
// Notification support requires API v25 or newer
bool get supportsNotifications => isConnected() && apiVersion >= 25;
// Supports 'modern' barcode API (v80 or newer)
bool get supportModernBarcodes => isConnected() && apiVersion >= 80;
// Structural categories requires API v83 or newer
bool get supportsStructuralCategories => isConnected() && apiVersion >= 83;
@ -883,6 +886,27 @@ class InvenTreeAPI {
);
}
/*
* Perform a request to link a custom barcode to a particular item
*/
Future<bool> linkBarcode(Map<String, String> body) async {
HttpClientRequest? request = await apiRequest("/barcode/link/", "POST");
if (request == null) {
return false;
}
final response = await completeRequest(
request,
data: json.encode(body),
statusCode: 200
);
return response.isValid() && response.statusCode == 200;
}
/*
* Perform a request to unlink a custom barcode from a particular item
*/
@ -1255,6 +1279,7 @@ class InvenTreeAPI {
);
}
// Return True if the API supports 'settings' (requires API v46)
bool get supportsSettings => isConnected() && apiVersion >= 46;
// Keep a record of which settings we have received from the server