From 429959ab31771d2596b84e81359f2c8e2f73a9a7 Mon Sep 17 00:00:00 2001 From: Ramon Bartl Date: Fri, 15 Nov 2024 10:48:13 +0100 Subject: [PATCH] Integrate transition chain shortcut --- src/bika/lims/workflow/analysis/events.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/bika/lims/workflow/analysis/events.py b/src/bika/lims/workflow/analysis/events.py index 46b829345e..38dbf03e86 100644 --- a/src/bika/lims/workflow/analysis/events.py +++ b/src/bika/lims/workflow/analysis/events.py @@ -30,8 +30,17 @@ from bika.lims.workflow.analysis import STATE_REJECTED from bika.lims.workflow.analysis import STATE_RETRACTED from DateTime import DateTime +from zope.annotation.interfaces import IAnnotations +from zope.interface import Interface from zope.interface import alsoProvides +try: + # https://github.com/senaite/senaite.app.listing/pull/146 + from senaite.app.listing.interfaces import ITransitionChain +except ImportError: + class ITransitionChain(Interface): + pass + def after_assign(analysis): """Function triggered after an 'assign' transition for the analysis passed @@ -253,6 +262,16 @@ def check_all_verified(analysis): :param analysis: The current verified analysis :returns: True if all other routine analyses of the sample are verified """ + + request = api.get_request() + if ITransitionChain.providedBy(request): + transition_chain = IAnnotations(request).get("transition_chain") + if api.is_list(transition_chain) and len(transition_chain) > 0: + # check if the current processed UID is the last + uid = api.get_uid(analysis) + # skip further processing if the current UID is not the last + return uid == transition_chain[-1] + parent = api.get_parent(analysis) sample = analysis.getRequest() uid = api.get_uid(analysis)