Passed
Push — 2.x ( 9aebce...13ead5 )
by Ramon
07:01
created

senaite.core.patches.workflow   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A _reindexWorkflowVariables() 0 22 2
1
# -*- coding: utf-8 -*-
2
3
from bika.lims import api
4
5
6
def _reindexWorkflowVariables(self, ob):
7
    """This function is called by DCWorkflow immediately after the workflow
8
    action is invoked in WorkflowTool.doActionFor.
9
10
    The original function is only responsible of reindexing the variables that
11
    may have changed due to the transition (e.g review_state) along with
12
    security-related indexes. However, the original function does two calls
13
    to reindexObject, one for workflow variables and another one for the
14
    security-related indexes. Metadata is updated on both calls as well, cause
15
    those workflow-variables might also be stored as metadata.
16
17
    Since quite often the transition involves changes not only in
18
    workflow-related variables, but to other field values, it becomes almost
19
    a requirement to always reindex the object after a transition. Therefore,
20
    we simply do a full reindexObject here instead of taking only some indexes
21
    into account.
22
    """
23
    if api.is_temporary(ob):
24
        return
25
26
    # do a full reindex
27
    ob.reindexObject()
28