Perform "addstock" action

This commit is contained in:
Oliver Walters 2020-04-09 22:56:28 +10:00
parent 1ec0b13479
commit 4cafa668a5
4 changed files with 90 additions and 11 deletions

View file

@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'model.dart';
import 'package:InvenTree/api.dart';
@ -155,6 +156,29 @@ class InvenTreeStockItem extends InvenTreeModel {
return item;
}
Future<http.Response> addStock(double quan) async {
// Cannot add stock to a serialized StockItem
if (isSerialized()) {
return null;
}
// Cannot add negative stock
if (quan <= 0) {
return null;
}
Map<String, dynamic> data = {
"item": {
"pk": "${pk}",
"quantity": "${quan}",
}
};
return api.post("/stock/add/", body: data);
}
}
@ -196,5 +220,4 @@ class InvenTreeStockLocation extends InvenTreeModel {
return loc;
}
}