2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-17 12:45:26 +00:00

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

@ -102,7 +102,7 @@ class InvenTreeModel {
print("GET: $addr ${params.toString()}");
var response = await InvenTreeAPI().get(addr, params: params);
var response = await api.get(addr, params: params);
if (response.statusCode != 200) {
print("Error retrieving data");
@ -134,7 +134,7 @@ class InvenTreeModel {
// TODO - Add "timeout"
// TODO - Add error catching
var response = await InvenTreeAPI().get(URL, params:params);
var response = await api.get(URL, params:params);
// A list of "InvenTreeModel" items
List<InvenTreeModel> results = new List<InvenTreeModel>();

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;
}
}