Skip to content

Commit 0a022d3

Browse files
xisparamonski
authored andcommitted
Inconsistences when applying Worksheet Templates (#499)
* When a worksheet template is used, slot positions are not applied correctly * Redux * Add reference samples in accordance with Worksheet Template Layout * Added get_analyses_at and get_container_at * Added doctest for WorksheetTemplate assignment to Worksheet * Simplify the logic that adds a duplicate from a WST in a Worksheet * Cleanup and redux * Removed pdb * Revisited and sanitized AddDuplicates logic * Remove setWorksheetTemplate and delegate the action to applyWorksheetTemplate * Addition of Reference Analyses test and sanitize * Ensure consistency when adding reference analyses in a worksheet * Added more tests when adding/removing reference analyses in a WS * Small fixes * Fix refgroupid for duplicates * All duplicates/references from same slot must have same group ID * Always keep the order by position of the ws layout, just in case * Let worksheet machinery to deal in which slot a duplicate must be added * Changelog * Organize imports and some PEP8 * Missing imports * Fix test TestAddDuplicateAnalysis.test_LIMS2001 * RST formatting only * PEP8 * Minor refactoring * rst formatting only * Refactored list of allowed analyses types * Additional test added
1 parent c7ceaa1 commit 0a022d3

File tree

7 files changed

+1373
-373
lines changed

7 files changed

+1373
-373
lines changed

CHANGES.rst

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Changelog
1515

1616
**Fixed**
1717

18+
- #499 Wrong slots when adding analyses manually in Worksheet with a WST assigned
19+
- #499 When a Worksheet Template is used, slot positions are not applied correctly
20+
- #499 Applying a WS template which references a Duplicate raises an Error
1821
- #513 ShowPrices doctest is failing
1922
- #488 JS Errors in bika.lims.analysisrequest.js
2023

bika/lims/browser/worksheet/views/add_duplicate.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ def __call__(self):
4747
ar_uid = self.request.get('ar_uid', '')
4848
src_slot = [slot['position'] for slot in self.context.getLayout() if
4949
slot['container_uid'] == ar_uid and slot['type'] == 'a'][0]
50-
position = self.request.get('position', '')
5150
self.request['context_uid'] = self.context.UID()
52-
self.context.addDuplicateAnalyses(src_slot, position)
51+
self.context.addDuplicateAnalyses(src_slot)
5352
self.request.response.redirect(self.context.absolute_url() + "/manage_results")
5453
else:
5554
self.ARs = AnalysisRequestsView(self.context, self.request)

bika/lims/browser/worksheet/views/add_worksheet.py

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def __call__(self):
5959
return
6060

6161
wst = rc.lookupObject(template)
62-
ws.setWorksheetTemplate(wst)
6362
ws.applyWorksheetTemplate(wst)
6463

6564
if ws.getLayout():

bika/lims/content/duplicateanalysis.py

+2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ def getSiblings(self, retracted=False):
116116
@security.public
117117
def setAnalysis(self, analysis):
118118
# Copy all the values from the schema
119+
if not analysis:
120+
return
119121
discard = ['id', ]
120122
keys = analysis.Schema().keys()
121123
for key in keys:

bika/lims/content/reflexrule.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def _createWorksheet(base, worksheettemplate, analyst):
391391
Analyst=analyst,
392392
)
393393
if worksheettemplate:
394-
ws.setWorksheetTemplate(worksheettemplate)
394+
ws.applyWorksheetTemplate(worksheettemplate)
395395
return ws
396396

397397

0 commit comments

Comments
 (0)