mirror of
https://github.com/inventree/inventree-app.git
synced 2025-08-07 04:52:08 +00:00
Add class for StockItemTestResult
This commit is contained in:
@@ -1,10 +1,34 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'model.dart';
|
||||
|
||||
import 'package:InvenTree/api.dart';
|
||||
|
||||
|
||||
class InvenTreeStockItemTestResult extends InvenTreeModel {
|
||||
|
||||
@override
|
||||
String NAME = "StockItemTestResult";
|
||||
|
||||
@override
|
||||
String URL = "stock/test/";
|
||||
|
||||
InvenTreeStockItemTestResult() : super();
|
||||
|
||||
InvenTreeStockItemTestResult.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
}
|
||||
|
||||
@override
|
||||
InvenTreeStockItemTestResult createFromJson(Map<String, dynamic> json) {
|
||||
var result = InvenTreeStockItemTestResult.fromJson(json);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class InvenTreeStockItem extends InvenTreeModel {
|
||||
|
||||
@override
|
||||
@@ -43,6 +67,29 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
// TODO
|
||||
}
|
||||
|
||||
List<InvenTreeStockItemTestResult> testResults = List<InvenTreeStockItemTestResult>();
|
||||
|
||||
int get testResultCount => testResults.length;
|
||||
|
||||
Future<void> getTestResults(BuildContext context, {bool showDialog=false}) async {
|
||||
InvenTreeStockItemTestResult().list(
|
||||
context,
|
||||
filters: {
|
||||
"stock_item": "${pk}",
|
||||
"user_detail": "true",
|
||||
},
|
||||
dialog: showDialog,
|
||||
).then((var results) {
|
||||
testResults.clear();
|
||||
|
||||
for (var r in results) {
|
||||
if (r is InvenTreeStockItemTestResult) {
|
||||
testResults.add(r);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
int get partId => jsondata['part'] ?? -1;
|
||||
|
||||
int get trackingItemCount => jsondata['tracking_items'] as int ?? 0;
|
||||
|
Reference in New Issue
Block a user