Fix: ensure apply ai suggestions runs after document created

This commit is contained in:
shamoon
2026-09-02 08:58:45 -07:00
parent c2a9532b8f
commit 47562449f4
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -1003,7 +1003,7 @@ def run_workflows(
# kwargs so the PaperlessTask record can note the
# document, see _extract_input_data
apply_ai_suggestions.delay(
apply_ai_suggestions.delay_on_commit(
action_id=action.pk,
document_id=document.pk,
)
+5 -1
View File
@@ -5621,11 +5621,15 @@ class TestApplyAISuggestionsWorkflowAction(
action = self.make_action()
self.make_workflow(action, WorkflowTrigger.WorkflowTriggerType.DOCUMENT_ADDED)
with mock.patch("documents.tasks.apply_ai_suggestions.delay") as delay:
with (
mock.patch("documents.tasks.apply_ai_suggestions.delay") as delay,
self.captureOnCommitCallbacks(execute=True),
):
run_workflows(
WorkflowTrigger.WorkflowTriggerType.DOCUMENT_ADDED,
self.doc,
)
delay.assert_not_called()
delay.assert_called_once_with(action_id=action.pk, document_id=self.doc.pk)