A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: use original_file when attaching docs to workflow emails with added trigger (#11266)
shamoona9dfe8f3f705
diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.pyindex 8862b064b..22abf625e 100644--- a/src/documents/signals/handlers.py+++ b/src/documents/signals/handlers.py@@ -31,6 +31,8 @@ from guardian.shortcuts import remove_permfrom documents import matchingfrom documents.caching import clear_document_caches+from documents.data_models import ConsumableDocument+from documents.data_models import DocumentSourcefrom documents.file_handling import create_source_path_directoryfrom documents.file_handling import delete_empty_directoriesfrom documents.file_handling import generate_unique_filename@@ -55,7 +57,6 @@ from documents.templating.workflows import parse_w_workflow_placeholdersif TYPE_CHECKING:from documents.classifier import DocumentClassifier- from documents.data_models import ConsumableDocumentfrom documents.data_models import DocumentMetadataOverrideslogger = logging.getLogger("paperless.handlers")@@ -1163,8 +1164,21 @@ def run_workflows()try:attachments = []- if action.email.include_document and original_file:- attachments = [document]+ if action.email.include_document:+ if trigger_type in [+ WorkflowTrigger.WorkflowTriggerType.DOCUMENT_UPDATED,+ WorkflowTrigger.WorkflowTriggerType.SCHEDULED,+ ]:+ # Updated and scheduled can pass the document directly+ attachments = [document]+ elif original_file:+ # For consumed and added document is not yet saved, so pass the original file+ attachments = [+ ConsumableDocument(+ source=DocumentSource.ApiUpload,+ original_file=original_file,+ ),+ ]n_messages = send_email(subject=subject,body=body,