Code Duplication    Length = 10-12 lines in 2 locations

bika/lims/content/referenceanalysis.py 1 location

@@ 172-181 (lines=10) @@
169
        # then attach the worksheet.
170
        ws = self.getWorksheet()
171
        ws_state = workflow.getInfoFor(ws, 'review_state')
172
        if ws_state == 'attachment_due' and not skip(ws, "attach", peek=True):
173
            can_attach = True
174
            for a in ws.getAnalyses():
175
                if workflow.getInfoFor(a, 'review_state') in \
176
                        ('sample_due', 'sample_received', 'attachment_due',
177
                         'assigned',):
178
                    can_attach = False
179
                    break
180
            if can_attach:
181
                workflow.doActionFor(ws, 'attach')
182
        self.reindexObject()
183
184

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

@@ 200-211 (lines=12) @@
197
    ws = obj.getWorksheet()
198
    if ws:
199
        ws_state = workflow.getInfoFor(ws, "review_state")
200
        if ws_state == "attachment_due" \
201
                and not skip(ws, "attach", peek=True):
202
            can_attach = True
203
            for a in ws.getAnalyses():
204
                state = workflow.getInfoFor(a, "review_state")
205
                if state in ("unassigned", "assigned", "attachment_due"):
206
                    can_attach = False
207
                    break
208
            if can_attach:
209
                workflow.doActionFor(ws, "attach")
210
    obj.reindexObject()
211
    reindex_request(obj)
212
213
214
# TODO Workflow - Analysis - revisit reindexing of ancestors