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

Create detail view for part stock

- Shows all in-stock stock items
This commit is contained in:
Oliver Walters
2021-01-20 23:56:25 +11:00
parent 15fee106b5
commit 83465511aa
5 changed files with 168 additions and 10 deletions

View File

@ -147,10 +147,38 @@ class InvenTreePart extends InvenTreeModel {
};
}
// Cached list of stock items
List<InvenTreeStockItem> stockItems = List<InvenTreeStockItem>();
int get stockItemCount => stockItems.length;
// Request stock items for this part
Future<void> getStockItems(BuildContext context, {bool showDialog=false}) async {
InvenTreeStockItem().list(
context,
filters: {
"part": "${pk}",
"in_stock": "true",
},
dialog: showDialog,
).then((var items) {
stockItems.clear();
for (var item in items) {
if (item is InvenTreeStockItem) {
stockItems.add(item);
}
}
});
}
// Cached list of test templates
List<InvenTreePartTestTemplate> testingTemplates = List<InvenTreePartTestTemplate>();
int get testTemplateCount => testingTemplates.length;
// Request test templates from the serve
Future<void> getTestTemplates(BuildContext context, {bool showDialog=false}) async {
InvenTreePartTestTemplate().list(

View File

@ -283,9 +283,9 @@ class InvenTreeStockItem extends InvenTreeModel {
String get locationName {
String loc = '';
if (jsondata.containsKey('location_detail')) {
loc = jsondata['location_detail']['name'] ?? '';
}
if (locationId == -1 || !jsondata.containsKey('location_detail')) return 'Unknown Location';
loc = jsondata['location_detail']['name'] ?? '';
// Old-style name
if (loc.isEmpty) {
@ -298,11 +298,9 @@ class InvenTreeStockItem extends InvenTreeModel {
String get locationPathString {
String path = '';
if (jsondata.containsKey('location_detail')) {
path = jsondata['location_detail']['pathstring'] ?? '';
}
if (locationId == -1 || !jsondata.containsKey('location_detail')) return 'No location specified';
return path;
return jsondata['location_detail']['pathstring'] ?? '';
}
String get displayQuantity {