mirror of
https://github.com/inventree/inventree-app.git
synced 2026-09-09 03:10:14 +00:00
Legacy prune (#850)
* Update minimum supported API version * Remove legacy search support * Remove supportsContactModel * More updates * Final updates * Remove broken ref
This commit is contained in:
@@ -241,7 +241,7 @@ class _PurchaseOrderDetailState
|
||||
List<SpeedDialChild> barcodeButtons(BuildContext context) {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (api.supportsBarcodePOReceiveEndpoint && widget.order.isPlaced) {
|
||||
if (widget.order.isPlaced) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
@@ -258,7 +258,7 @@ class _PurchaseOrderDetailState
|
||||
);
|
||||
}
|
||||
|
||||
if (widget.order.isPending && api.supportsBarcodePOAddLineEndpoint) {
|
||||
if (widget.order.isPending) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: COLOR_SUCCESS),
|
||||
@@ -288,12 +288,10 @@ class _PurchaseOrderDetailState
|
||||
INV_PO_SHOW_CAMERA,
|
||||
true,
|
||||
);
|
||||
supportProjectCodes =
|
||||
api.supportsProjectCodes &&
|
||||
await api.getGlobalBooleanSetting(
|
||||
"PROJECT_CODES_ENABLED",
|
||||
backup: true,
|
||||
);
|
||||
supportProjectCodes = await api.getGlobalBooleanSetting(
|
||||
"PROJECT_CODES_ENABLED",
|
||||
backup: true,
|
||||
);
|
||||
|
||||
completedLines = 0;
|
||||
|
||||
@@ -367,11 +365,6 @@ class _PurchaseOrderDetailState
|
||||
// Cannot edit supplier field from here
|
||||
fields.remove("supplier");
|
||||
|
||||
// Contact model not supported by server
|
||||
if (!api.supportsContactModel) {
|
||||
fields.remove("contact");
|
||||
}
|
||||
|
||||
// ProjectCode model not supported by server
|
||||
if (!supportProjectCodes) {
|
||||
fields.remove("project_code");
|
||||
|
||||
@@ -79,17 +79,15 @@ class _PurchaseOrderListWidgetState
|
||||
List<SpeedDialChild> barcodeButtons(BuildContext context) {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (api.supportsBarcodePOReceiveEndpoint) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap: () async {
|
||||
scanBarcode(context, handler: POReceiveBarcodeHandler());
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap: () async {
|
||||
scanBarcode(context, handler: POReceiveBarcodeHandler());
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@@ -239,20 +239,18 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
),
|
||||
);
|
||||
|
||||
if (api.supportsBarcodeSOAllocateEndpoint) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.transition_right),
|
||||
label: L10().allocateStock,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: SOAllocateStockHandler(salesOrder: widget.order),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.transition_right),
|
||||
label: L10().allocateStock,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: SOAllocateStockHandler(salesOrder: widget.order),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return actions;
|
||||
@@ -263,12 +261,10 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
await widget.order.reload();
|
||||
await api.SalesOrderStatus.load();
|
||||
|
||||
supportsProjectCodes =
|
||||
api.supportsProjectCodes &&
|
||||
await api.getGlobalBooleanSetting(
|
||||
"PROJECT_CODES_ENABLED",
|
||||
backup: true,
|
||||
);
|
||||
supportsProjectCodes = await api.getGlobalBooleanSetting(
|
||||
"PROJECT_CODES_ENABLED",
|
||||
backup: true,
|
||||
);
|
||||
showCameraShortcut = await InvenTreeSettingsManager().getBool(
|
||||
INV_SO_SHOW_CAMERA,
|
||||
true,
|
||||
@@ -312,11 +308,6 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
|
||||
|
||||
fields.remove("customer");
|
||||
|
||||
// Contact model not supported by server
|
||||
if (!api.supportsContactModel) {
|
||||
fields.remove("contact");
|
||||
}
|
||||
|
||||
// ProjectCode model not supported by server
|
||||
if (!supportsProjectCodes) {
|
||||
fields.remove("project_code");
|
||||
|
||||
@@ -128,23 +128,21 @@ class _SOLineDetailWidgetState extends RefreshableState<SoLineDetailWidget> {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (order != null && order!.isOpen && InvenTreeSOLineItem().canCreate) {
|
||||
if (api.supportsBarcodeSOAllocateEndpoint) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.transition_right),
|
||||
label: L10().allocateStock,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: SOAllocateStockHandler(
|
||||
salesOrder: order,
|
||||
lineItem: widget.item,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.transition_right),
|
||||
label: L10().allocateStock,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: SOAllocateStockHandler(
|
||||
salesOrder: order,
|
||||
lineItem: widget.item,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return actions;
|
||||
|
||||
@@ -192,7 +192,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
if (parent != null) {
|
||||
filters["parent"] = parent.toString();
|
||||
} else if (api.supportsNullTopLevelFiltering) {
|
||||
} else {
|
||||
filters["parent"] = "null";
|
||||
}
|
||||
|
||||
|
||||
+25
-112
@@ -255,124 +255,37 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
return;
|
||||
}
|
||||
|
||||
// Consolidated search allows us to perform *all* searches in a single query
|
||||
if (api.supportsConsolidatedSearch) {
|
||||
Map<String, dynamic> body = {
|
||||
"limit": 1,
|
||||
"search": term,
|
||||
Map<String, dynamic> body = {
|
||||
"limit": 1,
|
||||
"search": term,
|
||||
|
||||
InvenTreePart.MODEL_TYPE: {},
|
||||
InvenTreePartCategory.MODEL_TYPE: {},
|
||||
InvenTreeStockItem.MODEL_TYPE: {},
|
||||
InvenTreeStockLocation.MODEL_TYPE: {},
|
||||
InvenTreePurchaseOrder.MODEL_TYPE: {},
|
||||
InvenTreeSalesOrder.MODEL_TYPE: {},
|
||||
InvenTreeSupplierPart.MODEL_TYPE: {},
|
||||
InvenTreeManufacturerPart.MODEL_TYPE: {},
|
||||
};
|
||||
InvenTreePart.MODEL_TYPE: {},
|
||||
InvenTreePartCategory.MODEL_TYPE: {},
|
||||
InvenTreeStockItem.MODEL_TYPE: {},
|
||||
InvenTreeStockLocation.MODEL_TYPE: {},
|
||||
InvenTreePurchaseOrder.MODEL_TYPE: {},
|
||||
InvenTreeSalesOrder.MODEL_TYPE: {},
|
||||
InvenTreeSupplierPart.MODEL_TYPE: {},
|
||||
InvenTreeManufacturerPart.MODEL_TYPE: {},
|
||||
};
|
||||
|
||||
if (api.supportsSplitCompanySearch) {
|
||||
body["supplier"] = {};
|
||||
body["manufacturer"] = {};
|
||||
body["customer"] = {};
|
||||
} else {
|
||||
// All "company" results are returned in a single query
|
||||
body[InvenTreeCompany.MODEL_TYPE] = {};
|
||||
}
|
||||
|
||||
if (body.isNotEmpty) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
nPendingSearches = 1;
|
||||
});
|
||||
|
||||
_search_query = CancelableOperation.fromFuture(_perform_search(body));
|
||||
}
|
||||
}
|
||||
if (api.supportsSplitCompanySearch) {
|
||||
body["supplier"] = {};
|
||||
body["manufacturer"] = {};
|
||||
body["customer"] = {};
|
||||
} else {
|
||||
legacySearch(term);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform "legacy" search (without consolidated search API endpoint
|
||||
*/
|
||||
Future<void> legacySearch(String term) async {
|
||||
// Search parts
|
||||
if (InvenTreePart().canView) {
|
||||
nPendingSearches++;
|
||||
InvenTreePart().count(searchQuery: term).then((int n) {
|
||||
if (term == searchController.text) {
|
||||
if (mounted) {
|
||||
decrementPendingSearches();
|
||||
setState(() {
|
||||
nPartResults = n;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
// All "company" results are returned in a single query
|
||||
body[InvenTreeCompany.MODEL_TYPE] = {};
|
||||
}
|
||||
|
||||
// Search part categories
|
||||
if (InvenTreePartCategory().canView) {
|
||||
nPendingSearches++;
|
||||
InvenTreePartCategory().count(searchQuery: term).then((int n) {
|
||||
if (term == searchController.text) {
|
||||
if (mounted) {
|
||||
decrementPendingSearches();
|
||||
setState(() {
|
||||
nCategoryResults = n;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (body.isNotEmpty) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
nPendingSearches = 1;
|
||||
});
|
||||
|
||||
// Search stock items
|
||||
if (InvenTreeStockItem().canView) {
|
||||
nPendingSearches++;
|
||||
InvenTreeStockItem().count(searchQuery: term).then((int n) {
|
||||
if (term == searchController.text) {
|
||||
if (mounted) {
|
||||
decrementPendingSearches();
|
||||
setState(() {
|
||||
nStockResults = n;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Search stock locations
|
||||
if (InvenTreeStockLocation().canView) {
|
||||
nPendingSearches++;
|
||||
InvenTreeStockLocation().count(searchQuery: term).then((int n) {
|
||||
if (term == searchController.text) {
|
||||
if (mounted) {
|
||||
decrementPendingSearches();
|
||||
setState(() {
|
||||
nLocationResults = n;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Search purchase orders
|
||||
if (InvenTreePurchaseOrder().canView) {
|
||||
nPendingSearches++;
|
||||
InvenTreePurchaseOrder()
|
||||
.count(searchQuery: term, filters: {"outstanding": "true"})
|
||||
.then((int n) {
|
||||
if (term == searchController.text) {
|
||||
if (mounted) {
|
||||
decrementPendingSearches();
|
||||
setState(() {
|
||||
nPurchaseOrderResults = n;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
_search_query = CancelableOperation.fromFuture(_perform_search(body));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,20 +101,18 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
if (api.supportsBarcodePOReceiveEndpoint) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: POReceiveBarcodeHandler(location: location),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: POReceiveBarcodeHandler(location: location),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// Scan this location into another one
|
||||
if (InvenTreeStockLocation().canEdit) {
|
||||
@@ -362,7 +360,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
|
||||
if (parent != null) {
|
||||
filters["parent"] = parent.toString();
|
||||
} else if (api.supportsNullTopLevelFiltering) {
|
||||
} else {
|
||||
filters["parent"] = "null";
|
||||
}
|
||||
|
||||
|
||||
@@ -112,10 +112,6 @@ class _PaginatedStockItemListState
|
||||
},
|
||||
};
|
||||
|
||||
if (!InvenTreeAPI().supportsStatusLabelEndpoints) {
|
||||
filters.remove("status");
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user