Code Duplication    Length = 10-12 lines in 2 locations

bika/lims/content/referenceanalysis.py 1 location

@@ 187-196 (lines=10) @@
184
        ws = self.getBackReferences('WorksheetAnalysis')
185
        ws = ws[0]
186
        ws_state = workflow.getInfoFor(ws, 'review_state')
187
        if ws_state == 'attachment_due' and not skip(ws, "attach", peek=True):
188
            can_attach = True
189
            for a in ws.getAnalyses():
190
                if workflow.getInfoFor(a, 'review_state') in \
191
                        ('sample_due', 'sample_received', 'attachment_due',
192
                         'assigned',):
193
                    can_attach = False
194
                    break
195
            if can_attach:
196
                workflow.doActionFor(ws, 'attach')
197
        self.reindexObject()
198
199
    def workflow_script_retract(self):

bika/lims/workflow/analysis/events.py 1 location

@@ 192-203 (lines=12) @@
189
    ws = obj.getBackReferences('WorksheetAnalysis')
190
    if ws:
191
        ws_state = workflow.getInfoFor(ws, "review_state")
192
        if ws_state == "attachment_due" \
193
                and not skip(ws, "attach", peek=True):
194
            can_attach = True
195
            for a in ws.getAnalyses():
196
                state = workflow.getInfoFor(a, "review_state")
197
                if state in ("to_be_sampled", "to_be_preserved",
198
                             "sample_due", "sample_received",
199
                             "attachment_due", "assigned"):
200
                    can_attach = False
201
                    break
202
            if can_attach:
203
                workflow.doActionFor(ws, "attach")
204
    obj.reindexObject()
205
    reindex_request(obj)
206