diff --git a/CHANGES.rst b/CHANGES.rst index 91b1198180..1507dfba60 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,7 @@ Changelog 2.6.0 (unreleased) ------------------ +- #2598 Fix analyses from partitions are considered in manage analyses view - #2661 Allow to recalculate an analysis result - #2659 Refactor sample title + decsription into viewlets - #2660 Add logging if external calculation module import failed diff --git a/src/bika/lims/browser/analysisrequest/manage_analyses.py b/src/bika/lims/browser/analysisrequest/manage_analyses.py index e9da1a8c12..33f48f45a1 100644 --- a/src/bika/lims/browser/analysisrequest/manage_analyses.py +++ b/src/bika/lims/browser/analysisrequest/manage_analyses.py @@ -123,7 +123,7 @@ def update(self): """Update hook """ super(AnalysisRequestAnalysesView, self).update() - analyses = self.context.getAnalyses(full_objects=True) + analyses = self.context.objectValues("Analysis") self.analyses = dict([(a.getServiceUID(), a) for a in analyses]) @view.memoize diff --git a/src/senaite/core/datamanagers/field/sample_analyses.py b/src/senaite/core/datamanagers/field/sample_analyses.py index d82c40fe20..6257e3a99a 100644 --- a/src/senaite/core/datamanagers/field/sample_analyses.py +++ b/src/senaite/core/datamanagers/field/sample_analyses.py @@ -104,7 +104,6 @@ def set(self, items, prices, specs, hidden, **kw): # Get all analyses (those from descendants included) analyses = self.context.objectValues("Analysis") - analyses.extend(self.get_analyses_from_descendants(self.context)) # Bail out those not in services list or submitted uids = map(api.get_uid, services) @@ -328,14 +327,6 @@ def resolve_analyses(self, instance, service): return analyses - def get_analyses_from_descendants(self, instance): - """Returns all the analyses from descendants - """ - analyses = [] - for descendant in instance.getDescendants(all_descendants=True): - analyses.extend(descendant.objectValues("Analysis")) - return analyses - def get_from_instance(self, instance, service): """Returns analyses for the given service from the instance """ diff --git a/src/senaite/core/tests/doctests/ARAnalysesFieldWithPartitions.rst b/src/senaite/core/tests/doctests/ARAnalysesFieldWithPartitions.rst index ed13081a63..111ab43b8e 100644 --- a/src/senaite/core/tests/doctests/ARAnalysesFieldWithPartitions.rst +++ b/src/senaite/core/tests/doctests/ARAnalysesFieldWithPartitions.rst @@ -204,17 +204,6 @@ But returns None if I ask to the partition: >>> dm.get_from_descendant(partition, Cu) [] -get_analyses_from_descendants -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -It returns the analyses contained by the descendants: - - >>> dm.get_analyses_from_descendants(sample) - [] - - >>> dm.get_analyses_from_descendants(partition) - [] - Resolution of analyses from the Sample lineage .............................................. @@ -332,18 +321,22 @@ the partition: >>> partition.objectValues("Analysis") [, , , ] -To remove `Mg` analysis, pass the list without `Mg`: +Nothing happens if we try to remove `Mg` analysis from the sample, cause it +belongs to the partition: >>> field.set(sample, [Cu, Fe, Au]) - -The analysis `Mg` has been removed, although it belonged to the partition: - >>> sample.objectValues("Analysis") [] >>> partition.objectValues("Analysis") + [, , , ] + +We have explicitly remove the analysis from the partition instead: + + >>> field.set(partition, [Cu, Fe, Au]) + >>> partition.objectValues("Analysis") [, , ] -But if I add a new analysis to the primary and I try to remove it from the +If I add a new analysis to the primary and I try to remove it from the partition, nothing will happen: >>> field.set(sample, [Cu, Fe, Au, Mg])