mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Support barcode scan for purchase order (#298)
* Add functions for determining API support levels * Handle scanning of purchase orders
This commit is contained in:
parent
fb0a383fff
commit
f7d3315c99
12
lib/api.dart
12
lib/api.dart
@ -282,6 +282,18 @@ class InvenTreeAPI {
|
||||
// Consolidated search request API v102 or newer
|
||||
bool get supportsConsolidatedSearch => isConnected() && apiVersion >= 102;
|
||||
|
||||
// ReturnOrder supports API v104 or newer
|
||||
bool get supportsReturnOrders => isConnected() && apiVersion >= 104;
|
||||
|
||||
// Status label endpoints API v105 or newer
|
||||
bool get supportsStatusLabelEndpoints => isConnected() && apiVersion >= 105;
|
||||
|
||||
// Regex search API v106 or newer
|
||||
bool get supportsRegexSearch => isConnected() && apiVersion >= 106;
|
||||
|
||||
// Order barcodes API v107 or newer
|
||||
bool get supportsOrderBarcodes => isConnected() && apiVersion >= 107;
|
||||
|
||||
// Are plugins enabled on the server?
|
||||
bool _pluginsEnabled = false;
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
import "dart:io";
|
||||
import "package:flutter/material.dart";
|
||||
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
||||
import "package:inventree/inventree/purchase_order.dart";
|
||||
import "package:inventree/widget/purchase_order_detail.dart";
|
||||
import "package:one_context/one_context.dart";
|
||||
import "package:qr_code_scanner/qr_code_scanner.dart";
|
||||
|
||||
@ -159,6 +161,7 @@ class BarcodeHandler {
|
||||
* - StockItem
|
||||
* - Part
|
||||
* - SupplierPart
|
||||
* - PurchaseOrder
|
||||
*/
|
||||
class BarcodeScanHandler extends BarcodeHandler {
|
||||
|
||||
@ -232,6 +235,21 @@ class BarcodeScanHandler extends BarcodeHandler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Response when a "PurchaseOrder" instance is scanned
|
||||
*/
|
||||
Future<void> handlePurchaseOrder(int pk) async {
|
||||
var order = await InvenTreePurchaseOrder().get(pk);
|
||||
|
||||
if (order is InvenTreePurchaseOrder) {
|
||||
OneContext().pop();
|
||||
OneContext().push(MaterialPageRoute(
|
||||
builder: (context) => PurchaseOrderDetailWidget(order)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Future<void> onBarcodeMatched(Map<String, dynamic> data) async {
|
||||
int pk = -1;
|
||||
@ -239,13 +257,18 @@ class BarcodeScanHandler extends BarcodeHandler {
|
||||
String model = "";
|
||||
|
||||
// The following model types can be matched with barcodes
|
||||
final List<String> validModels = [
|
||||
List<String> validModels = [
|
||||
"part",
|
||||
"stockitem",
|
||||
"stocklocation",
|
||||
"supplierpart"
|
||||
"supplierpart",
|
||||
];
|
||||
|
||||
|
||||
if (InvenTreeAPI().supportsOrderBarcodes) {
|
||||
validModels.add("purchaseorder");
|
||||
}
|
||||
|
||||
for (var key in validModels) {
|
||||
if (data.containsKey(key)) {
|
||||
pk = (data[key]?["pk"] ?? -1) as int;
|
||||
@ -276,6 +299,9 @@ class BarcodeScanHandler extends BarcodeHandler {
|
||||
case "supplierpart":
|
||||
await handleSupplierPart(pk);
|
||||
return;
|
||||
case "purchaseorder":
|
||||
await handlePurchaseOrder(pk);
|
||||
return;
|
||||
default:
|
||||
// Fall through to failure state
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user