|
8 | 8 | from AccessControl import getSecurityManager
|
9 | 9 | from bika.lims import bikaMessageFactory as _
|
10 | 10 | from bika.lims import PMF
|
| 11 | +from bika.lims.api import get_tool |
11 | 12 | from bika.lims.browser.bika_listing import WorkflowAction
|
12 | 13 | from bika.lims.browser.referenceanalysis import AnalysesRetractedListReport
|
| 14 | +from bika.lims.catalog.analysis_catalog import CATALOG_ANALYSIS_LISTING |
13 | 15 | from bika.lims.permissions import EditResults, EditWorksheet, ManageWorksheets
|
14 | 16 | from bika.lims.subscribers import doActionFor
|
15 | 17 | from bika.lims.subscribers import skip
|
@@ -105,16 +107,17 @@ def __call__(self):
|
105 | 107 | self.request.response.redirect(self.context.absolute_url())
|
106 | 108 | return
|
107 | 109 |
|
108 |
| - selected_analyses = WorkflowAction._get_selected_items(self) |
109 |
| - selected_analysis_uids = selected_analyses.keys() |
110 |
| - if selected_analyses: |
111 |
| - for uid in selected_analysis_uids: |
112 |
| - analysis = rc.lookupObject(uid) |
113 |
| - # Double-check the state first |
114 |
| - if (workflow.getInfoFor(analysis, 'worksheetanalysis_review_state') == 'unassigned' |
115 |
| - and workflow.getInfoFor(analysis, 'review_state') == 'sample_received' |
116 |
| - and workflow.getInfoFor(analysis, 'cancellation_state') == 'active'): |
117 |
| - self.context.addAnalysis(analysis) |
| 110 | + analysis_uids = form.get("uids", []) |
| 111 | + if analysis_uids: |
| 112 | + # We retrieve the analyses from the database sorted by AR ID |
| 113 | + # ascending, so the positions of the ARs inside the WS are |
| 114 | + # consistent with the order of the ARs |
| 115 | + catalog = get_tool(CATALOG_ANALYSIS_LISTING) |
| 116 | + brains = catalog({'UID': analysis_uids, |
| 117 | + 'sort_on': 'getRequestID'}) |
| 118 | + for brain in brains: |
| 119 | + analysis = brain.getObject() |
| 120 | + self.context.addAnalysis(analysis) |
118 | 121 |
|
119 | 122 | self.destination_url = self.context.absolute_url()
|
120 | 123 | self.request.response.redirect(self.destination_url)
|
|
0 commit comments