Skip to content

Commit

Permalink
Add api version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
30350n committed Sep 15, 2023
1 parent 8243299 commit 6146ddc
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 36 deletions.
2 changes: 2 additions & 0 deletions lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ class InvenTreeAPI {
// Does the server support extra fields on stock adjustment actions?
bool get supportsStockAdjustExtraFields => isConnected() && apiVersion >= 133;

bool get supportsBarcodePOReceiveEndpoint => isConnected() && apiVersion >= 135;

// Are plugins enabled on the server?
bool _pluginsEnabled = false;

Expand Down
26 changes: 14 additions & 12 deletions lib/widget/location_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,20 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
);
}

actions.add(
SpeedDialChild(
child: Icon(Icons.barcode_reader),
label: L10().scanReceivedParts,
onTap:() async {
scanBarcode(
context,
handler: POReceiveBarcodeHandler(location: location),
);
},
)
);
if (api.supportsBarcodePOReceiveEndpoint) {
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) {
Expand Down
26 changes: 14 additions & 12 deletions lib/widget/purchase_order_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,20 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
List<SpeedDialChild> barcodeButtons(BuildContext context) {
List<SpeedDialChild> actions = [];

actions.add(
SpeedDialChild(
child: Icon(Icons.barcode_reader),
label: L10().scanReceivedParts,
onTap:() async {
scanBarcode(
context,
handler: POReceiveBarcodeHandler(purchaseOrder: order),
);
},
)
);
if (api.supportsBarcodePOReceiveEndpoint) {
actions.add(
SpeedDialChild(
child: Icon(Icons.barcode_reader),
label: L10().scanReceivedParts,
onTap:() async {
scanBarcode(
context,
handler: POReceiveBarcodeHandler(purchaseOrder: order),
);
},
)
);
}

return actions;
}
Expand Down
26 changes: 14 additions & 12 deletions lib/widget/purchase_order_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,20 @@ class _PurchaseOrderListWidgetState extends RefreshableState<PurchaseOrderListWi
List<SpeedDialChild> barcodeButtons(BuildContext context) {
List<SpeedDialChild> actions = [];

actions.add(
SpeedDialChild(
child: Icon(Icons.barcode_reader),
label: L10().scanReceivedParts,
onTap:() async {
scanBarcode(
context,
handler: POReceiveBarcodeHandler(),
);
},
)
);
if (api.supportsBarcodePOReceiveEndpoint) {
actions.add(
SpeedDialChild(
child: Icon(Icons.barcode_reader),
label: L10().scanReceivedParts,
onTap:() async {
scanBarcode(
context,
handler: POReceiveBarcodeHandler(),
);
},
)
);
}

return actions;
}
Expand Down

0 comments on commit 6146ddc

Please sign in to comment.