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:
@ -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>();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user