Skip to content

Commit

Permalink
Merge pull request #575 from inventree/receive-location
Browse files Browse the repository at this point in the history
Receive location
  • Loading branch information
SchrodingersGat authored Dec 11, 2024
2 parents 35f3792 + 6690f10 commit e93e024
Show file tree
Hide file tree
Showing 31 changed files with 129 additions and 121 deletions.
2 changes: 2 additions & 0 deletions assets/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

- Fixes barcode scanning bug which prevents scanning of DataMatrix codes
- Display "destination" information in PurchaseOrder detail view
- Pre-fill "location" field when receiving items against PurchaseOrder
- Fix display of part name in PurchaseOrderLineItem list
- Adds "assigned to me" filter for Purchase Order list
- Adds "assigned to me" filter for Sales Order list

Expand Down
8 changes: 4 additions & 4 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -272,45 +272,45 @@
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/DKImagePickerController/DKImagePickerController.framework",
"${BUILT_PRODUCTS_DIR}/DKPhotoGallery/DKPhotoGallery.framework",
"${BUILT_PRODUCTS_DIR}/MTBBarcodeScanner/MTBBarcodeScanner.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework",
"${BUILT_PRODUCTS_DIR}/Sentry/Sentry.framework",
"${BUILT_PRODUCTS_DIR}/SwiftyGif/SwiftyGif.framework",
"${BUILT_PRODUCTS_DIR}/audioplayers_darwin/audioplayers_darwin.framework",
"${BUILT_PRODUCTS_DIR}/camera_avfoundation/camera_avfoundation.framework",
"${BUILT_PRODUCTS_DIR}/device_info_plus/device_info_plus.framework",
"${BUILT_PRODUCTS_DIR}/file_picker/file_picker.framework",
"${BUILT_PRODUCTS_DIR}/flutter_zxing/flutter_zxing.framework",
"${BUILT_PRODUCTS_DIR}/image_picker_ios/image_picker_ios.framework",
"${BUILT_PRODUCTS_DIR}/open_filex/open_filex.framework",
"${BUILT_PRODUCTS_DIR}/package_info_plus/package_info_plus.framework",
"${BUILT_PRODUCTS_DIR}/path_provider_foundation/path_provider_foundation.framework",
"${BUILT_PRODUCTS_DIR}/qr_code_scanner/qr_code_scanner.framework",
"${BUILT_PRODUCTS_DIR}/sentry_flutter/sentry_flutter.framework",
"${BUILT_PRODUCTS_DIR}/shared_preferences_foundation/shared_preferences_foundation.framework",
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework",
"${BUILT_PRODUCTS_DIR}/wakelock_plus/wakelock_plus.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DKImagePickerController.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DKPhotoGallery.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MTBBarcodeScanner.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Sentry.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyGif.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/audioplayers_darwin.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/camera_avfoundation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info_plus.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/file_picker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_zxing.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker_ios.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/open_filex.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info_plus.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_foundation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/qr_code_scanner.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sentry_flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_foundation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock_plus.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
6 changes: 3 additions & 3 deletions lib/api_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ Future<void> launchApiForm(
IconData icon = TablerIcons.device_floppy
}) async {

showLoadingOverlay(context);
showLoadingOverlay();

// List of fields defined by the server
Map<String, dynamic> serverFields = {};
Expand Down Expand Up @@ -1229,7 +1229,7 @@ class _APIFormWidgetState extends State<APIFormWidget> {

if (widget.method == "POST") {

showLoadingOverlay(context);
showLoadingOverlay();
final response = await InvenTreeAPI().post(
widget.url,
body: data,
Expand All @@ -1240,7 +1240,7 @@ class _APIFormWidgetState extends State<APIFormWidget> {
return response;

} else {
showLoadingOverlay(context);
showLoadingOverlay();
final response = await InvenTreeAPI().patch(
widget.url,
body: data,
Expand Down
40 changes: 38 additions & 2 deletions lib/barcode/camera_controller.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import "dart:math";
import "dart:typed_data";

import "package:camera/camera.dart";
import "package:flutter/material.dart";
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
import "package:inventree/app_colors.dart";
import "package:inventree/inventree/sentry.dart";
import "package:inventree/preferences.dart";
import "package:inventree/widget/snacks.dart";
import "package:one_context/one_context.dart";
import "package:wakelock_plus/wakelock_plus.dart";
import "package:flutter_zxing/flutter_zxing.dart";

Expand Down Expand Up @@ -133,7 +137,28 @@ class _CameraBarcodeControllerState extends InvenTreeBarcodeControllerState {
}
});
}
}

void onControllerCreated(CameraController? controller, Exception? error) {
if (error != null) {
sentryReportError(
"CameraBarcodeController.onControllerCreated",
error,
null
);
}

if (controller == null) {
showSnackIcon(
L10().cameraCreationError,
icon: TablerIcons.camera_x,
success: false
);

if (OneContext.hasContext) {
Navigator.pop(OneContext().context!);
}
}
}

/*
Expand Down Expand Up @@ -167,6 +192,7 @@ class _CameraBarcodeControllerState extends InvenTreeBarcodeControllerState {
tryInverted: true,
tryRotate: true,
showGallery: false,
onControllerCreated: onControllerCreated,
scanDelay: Duration(milliseconds: scan_delay),
resolution: ResolutionPreset.high,
lensDirection: CameraLensDirection.back,
Expand All @@ -185,7 +211,12 @@ class _CameraBarcodeControllerState extends InvenTreeBarcodeControllerState {
child: Align(
alignment: Alignment.topCenter,
child: Padding(
padding: EdgeInsets.all(10),
padding: EdgeInsets.only(
left: 10,
right: 10,
top: 75,
bottom: 10
),
child: Text(
widget.handler.getOverlayText(context),
style: TextStyle(
Expand Down Expand Up @@ -213,7 +244,12 @@ class _CameraBarcodeControllerState extends InvenTreeBarcodeControllerState {
child: Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: EdgeInsets.all(10),
padding: EdgeInsets.only(
left: 10,
right: 10,
top: 10,
bottom: 75
),
child: Text(
text,
textAlign: TextAlign.center,
Expand Down
12 changes: 1 addition & 11 deletions lib/barcode/controller.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import "package:flutter/material.dart";
import "package:inventree/helpers.dart";
import "package:one_context/one_context.dart";

import "package:inventree/preferences.dart";

import "package:inventree/barcode/handler.dart";

import "package:inventree/widget/progress.dart";

/*
Expand Down Expand Up @@ -59,13 +55,7 @@ class InvenTreeBarcodeControllerState extends State<InvenTreeBarcodeController>
processingBarcode = true;
});

BuildContext? context;

if (hasContext()) {
context = OneContext.hasContext ? OneContext().context : null;
}

showLoadingOverlay(context);
showLoadingOverlay();
await pauseScan();

await widget.handler.processBarcode(data);
Expand Down
9 changes: 1 addition & 8 deletions lib/inventree/bom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,14 @@ class InvenTreeBomItem extends InvenTreeModel {
String get URL => "bom/";

@override
Map<String, String> defaultListFilters() {
Map<String, String> defaultFilters() {
return {
"sub_part_detail": "true",
"part_detail": "true",
"show_pricing": "false",
};
}

@override
Map<String, String> defaultGetFilters() {
return {
"sub_part_detail": "true",
};
}

// Extract the 'reference' value associated with this BomItem
String get reference => getString("reference");

Expand Down
18 changes: 6 additions & 12 deletions lib/inventree/company.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,15 @@ class InvenTreeSupplierPart extends InvenTreeModel {
return fields;
}

Map<String, String> _filters() {
@override
Map<String, String> defaultFilters() {
return {
"manufacturer_detail": "true",
"supplier_detail": "true",
"part_detail": "true",
};
}

@override
Map<String, String> defaultListFilters() {
return _filters();
}

@override
Map<String, String> defaultGetFilters() {
return _filters();
}

int get manufacturerId => getInt("pk", subKey: "manufacturer_detail");

Expand All @@ -197,8 +189,10 @@ class InvenTreeSupplierPart extends InvenTreeModel {

String get partImage => (jsondata["part_detail"]?["thumbnail"] ?? InvenTreeAPI.staticThumb) as String;

String get partName => getString("full_name", subKey: "part_detail");

String get partName => getString("name", subKey: "part_detail");

Map<String, dynamic> get partDetail => getMap("part_detail");

String get partDescription => getString("description", subKey: "part_detail");

String get note => getString("note");
Expand Down
11 changes: 2 additions & 9 deletions lib/inventree/part.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,9 @@ class InvenTreePart extends InvenTreeModel {
}

@override
Map<String, String> defaultListFilters() {
Map<String, String> defaultFilters() {
return {
"location_detail": "true",
};
}

@override
Map<String, String> defaultGetFilters() {
return {
"category_detail": "true", // Include category detail information
"category_detail": "true",
};
}

Expand Down
26 changes: 10 additions & 16 deletions lib/inventree/purchase_order.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "package:inventree/helpers.dart";
import "package:inventree/inventree/company.dart";
import "package:inventree/inventree/model.dart";
import "package:inventree/inventree/orders.dart";
import "package:inventree/widget/progress.dart";


/*
Expand Down Expand Up @@ -64,14 +65,7 @@ class InvenTreePurchaseOrder extends InvenTreeOrder {
}

@override
Map<String, String> defaultGetFilters() {
return {
"supplier_detail": "true",
};
}

@override
Map<String, String> defaultListFilters() {
Map<String, String> defaultFilters() {
return {
"supplier_detail": "true",
};
Expand Down Expand Up @@ -128,7 +122,9 @@ class InvenTreePurchaseOrder extends InvenTreeOrder {
return;
}

showLoadingOverlay();
await api.post("${url}issue/", expectedStatusCode: 201);
hideLoadingOverlay();
}

/// Mark this order as "cancelled"
Expand All @@ -137,7 +133,9 @@ class InvenTreePurchaseOrder extends InvenTreeOrder {
return;
}

showLoadingOverlay();
await api.post("${url}cancel/", expectedStatusCode: 201);
hideLoadingOverlay();
}
}

Expand Down Expand Up @@ -178,16 +176,10 @@ class InvenTreePOLineItem extends InvenTreeOrderLine {
}

@override
Map<String, String> defaultGetFilters() {
return {
"part_detail": "true",
};
}

@override
Map<String, String> defaultListFilters() {
Map<String, String> defaultFilters() {
return {
"part_detail": "true",
"order_detail": "true",
};
}

Expand Down Expand Up @@ -228,6 +220,8 @@ class InvenTreePOLineItem extends InvenTreeOrderLine {

int get destinationId => getInt("destination");

Map<String, dynamic> get orderDetail => getMap("order_detail");

Map<String, dynamic> get destinationDetail => getMap("destination_detail");
}

Expand Down
Loading

0 comments on commit e93e024

Please sign in to comment.