mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-31 13:25:40 +00:00 
			
		
		
		
	Attachments fix (#528)
* Bump version * Fix for viewing and uploading attachment files - Make sure we use the correct attribute!
This commit is contained in:
		| @@ -1001,11 +1001,23 @@ class InvenTreeAttachment extends InvenTreeModel { | ||||
|     String url = URL; | ||||
|  | ||||
|     if (InvenTreeAPI().supportsModernAttachments) { | ||||
|       // All attachments are stored in a consolidated table | ||||
|  | ||||
|       if (modelType.isEmpty) { | ||||
|         sentryReportMessage("uploadAttachment called with empty 'modelType'"); | ||||
|         return false; | ||||
|       } | ||||
|  | ||||
|       url = "attachment/"; | ||||
|       data["model_id"] = modelId.toString(); | ||||
|       data["model_type"] = modelType; | ||||
|  | ||||
|     } else { | ||||
|  | ||||
|       if (REFERENCE_FIELD.isEmpty) { | ||||
|         sentryReportMessage("uploadAttachment called with empty 'REFERENCE_FIELD'"); | ||||
|         return false; | ||||
|       } | ||||
|  | ||||
|       data[REFERENCE_FIELD] = modelId.toString(); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -76,7 +76,11 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> { | ||||
|  | ||||
|     showLoadingOverlay(context); | ||||
|  | ||||
|     final bool result = await widget.attachmentClass.uploadAttachment(file, widget.attachmentClass.MODEL_TYPE, widget.modelId); | ||||
|     final bool result = await widget.attachmentClass.uploadAttachment( | ||||
|         file, | ||||
|         widget.attachmentClass.REF_MODEL_TYPE, | ||||
|         widget.modelId | ||||
|     ); | ||||
|  | ||||
|     hideLoadingOverlay(); | ||||
|  | ||||
| @@ -137,7 +141,7 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> { | ||||
|     Map<String, String> filters = {}; | ||||
|  | ||||
|     if (InvenTreeAPI().supportsModernAttachments) { | ||||
|       filters["model_type"] = widget.attachmentClass.MODEL_TYPE; | ||||
|       filters["model_type"] = widget.attachmentClass.REF_MODEL_TYPE; | ||||
|       filters["model_id"] = widget.modelId.toString(); | ||||
|     } else { | ||||
|       filters[widget.attachmentClass.REFERENCE_FIELD] = widget.modelId.toString(); | ||||
| @@ -148,10 +152,7 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> { | ||||
|     ).then((var results) { | ||||
|       attachments.clear(); | ||||
|  | ||||
|       print("Found ${results.length} results:"); | ||||
|  | ||||
|       for (var result in results) { | ||||
|         print(result.toString()); | ||||
|         if (result is InvenTreeAttachment) { | ||||
|           attachments.add(result); | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user