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

Barcode updates (#211)

* Adds API function for unlinking a barcode

* Show barcode unlink result

* Update release notes and version number
This commit is contained in:
Oliver
2022-09-15 14:22:40 +10:00
committed by GitHub
parent 87c8a21c3c
commit 6d796a2e32
4 changed files with 56 additions and 16 deletions

View File

@ -417,25 +417,43 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
}
/*
* Unassign (remove) a barcode from a StockItem.
*
* Note that for API version < 76 this action is performed on the StockItem endpoint.
* For API version 76 or above, this uses the barcode "unlink" endpoint
*/
Future<void> _unassignBarcode(BuildContext context) async {
final response = await item.update(values: {"uid": ""});
if (InvenTreeAPI().apiVersion < 76) {
final response = await item.update(values: {"uid": ""});
switch (response.statusCode) {
case 200:
case 201:
showSnackIcon(
L10().stockItemUpdateSuccess,
success: true
);
break;
default:
showSnackIcon(
L10().stockItemUpdateFailure,
success: false,
);
break;
switch (response.statusCode) {
case 200:
case 201:
showSnackIcon(
L10().stockItemUpdateSuccess,
success: true
);
break;
default:
showSnackIcon(
L10().stockItemUpdateFailure,
success: false,
);
break;
}
} else {
final bool result = await InvenTreeAPI().unlinkBarcode({
"stockitem": item.pk,
});
showSnackIcon(
result ? L10().stockItemUpdateSuccess : L10().stockItemUpdateFailure,
success: result,
);
}
refresh(context);
}