2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 02:05: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

@ -12,6 +12,7 @@ import "package:inventree/barcode.dart";
import "package:inventree/helpers.dart";
import "package:inventree/user_profile.dart";
import "package:inventree/inventree/part.dart";
import "package:inventree/inventree/stock.dart";
void main() {
@ -75,7 +76,7 @@ void main() {
debugContains("Scanned barcode data: '{\"stocklocation\": 999999}'");
debugContains("showSnackIcon: 'No match for barcode'");
assert(debugMessageCount() == 2);
assert(debugMessageCount() == 3);
});
});
@ -157,4 +158,42 @@ void main() {
debugContains("showSnackIcon: 'Scanned into location'");
});
});
group("Test PartBarcodes:", () {
// Assign a custom barcode to a Part instance
test("Assign Barcode", () async {
// Unlink barcode first
await InvenTreeAPI().unlinkBarcode({
"part": "2"
});
final part = await InvenTreePart().get(2) as InvenTreePart?;
assert(part != null);
assert(part!.pk == 2);
// Should have a "null" barcode
assert(part!.customBarcode.isEmpty);
// Assign custom barcode data to the part
await InvenTreeAPI().linkBarcode({
"part": "2",
"barcode": "xyz-123"
});
await part!.reload();
assert(part.customBarcode.isNotEmpty);
// Check we can de-register a barcode also
// Unlink barcode first
await InvenTreeAPI().unlinkBarcode({
"part": "2"
});
await part.reload();
assert(part.customBarcode.isEmpty);
});
});
}