2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-08-05 20:21:31 +00:00

Allow user to manually remove (delete) a StockItem

This commit is contained in:
Oliver Walters
2022-03-26 18:33:02 +11:00
parent 6c3b83c05b
commit ea724fcf5f
4 changed files with 101 additions and 7 deletions

View File

@@ -157,6 +157,27 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
});
}
/// Delete the stock item from the database
Future<void> _deleteItem(BuildContext context) async {
confirmationDialog(
L10().stockItemDelete,
L10().stockItemDeleteConfirm,
icon: FontAwesomeIcons.trashAlt,
onAccept: () async {
final bool result = await item.delete();
if (result) {
Navigator.of(context).pop();
showSnackIcon(L10().stockItemDeleteSuccess, success: true);
} else {
showSnackIcon(L10().stockItemDeleteFailure, success: false);
}
},
);
}
/// Opens a popup dialog allowing user to select a label for printing
Future <void> _printLabel(BuildContext context) async {
@@ -1003,6 +1024,19 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
);
}
// If the user has permission to delete this stock item
if (InvenTreeAPI().checkPermission("stock", "delete")) {
tiles.add(
ListTile(
title: Text("Delete Stock Item"),
leading: FaIcon(FontAwesomeIcons.trashAlt, color: COLOR_DANGER),
onTap: () {
_deleteItem(context);
},
)
);
}
return tiles;
}