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

@@ 185-196 (lines=12) @@
182
    ws = obj.getWorksheet()
183
    if ws:
184
        ws_state = workflow.getInfoFor(ws, "review_state")
185
        if ws_state == "attachment_due" \
186
                and not skip(ws, "attach", peek=True):
187
            can_attach = True
188
            for a in ws.getAnalyses():
189
                state = workflow.getInfoFor(a, "review_state")
190
                if state in ("unassigned", "assigned", "attachment_due"):
191
                    can_attach = False
192
                    break
193
            if can_attach:
194
                workflow.doActionFor(ws, "attach")
195
    obj.reindexObject()
196
    reindex_request(obj)
197
198
199
# TODO Workflow - Analysis - revisit reindexing of ancestors