From 60fb00ff2daae913a813121cd38fc80ca8cecb48 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 5 Apr 2018 19:57:26 -0400 Subject: [PATCH] Fix issue when using workflows transitions with the new version upload event as trigger. Thanks to Sema @Miggaten for the find and the solution. Signed-off-by: Roberto Rosario --- HISTORY.rst | 3 +++ docs/releases/3.0.rst | 4 +++- mayan/apps/document_states/handlers.py | 12 ++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 0fc53fdf23..3c85af574b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -137,6 +137,9 @@ - Improve line chart appearance. Fix mouse hover label issue. - Add JavaScript dependency manager. - Add support for passing arguments to the OCR backend. +- Fix issue when using workflows transitions with the new version + upload event as trigger. Thanks to Sema @Miggaten for the find and + the solution. 2.7.3 (2017-09-11) ================== diff --git a/docs/releases/3.0.rst b/docs/releases/3.0.rst index 4c5ba82440..5a7e0bc560 100644 --- a/docs/releases/3.0.rst +++ b/docs/releases/3.0.rst @@ -427,7 +427,9 @@ Other changes worth mentioning - Update Chart.js version. - Improve line chart appearance. Fix issue with mouse over labels next other chart margin. - Add support for passing arguments to the OCR backend. - +- Fix issue when using workflows transitions with the new version + upload event as trigger. Thanks to Sema @Miggaten for the find and + the solution. Removals diff --git a/mayan/apps/document_states/handlers.py b/mayan/apps/document_states/handlers.py index f874c12fbd..a008934fcc 100644 --- a/mayan/apps/document_states/handlers.py +++ b/mayan/apps/document_states/handlers.py @@ -39,12 +39,12 @@ def handler_trigger_transition(sender, **kwargs): for workflow_instance in workflow_instances: # Select the first transition that is valid for this workflow state - transition = list(set(trigger_transitions) & set(workflow_instance.get_transition_choices()))[0] - - workflow_instance.do_transition( - comment=_('Event trigger: %s') % EventType.get(name=action.verb).label, - transition=transition - ) + valid_transitions = list(set(trigger_transitions) & set(workflow_instance.get_transition_choices())) + if valid_transitions: + workflow_instance.do_transition( + comment=_('Event trigger: %s') % EventType.get(name=action.verb).label, + transition=valid_transitions[0] + ) def launch_workflow(sender, instance, created, **kwargs):