From 47b527dc838a51e0215793fa9789af11ba3cd99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Mon, 29 Jul 2024 11:12:54 +0200 Subject: [PATCH 1/4] Do not display analyses from other partitions in Manage analyses view --- src/bika/lims/browser/analysisrequest/manage_analyses.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 108c77d9dd60d46b08f45e9865a53662ddd3de5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Mon, 29 Jul 2024 11:14:46 +0200 Subject: [PATCH 2/4] Do not add/remove analyses from partitions on manage analyses --- .../core/datamanagers/field/sample_analyses.py | 9 --------- .../tests/doctests/ARAnalysesFieldWithPartitions.rst | 11 ----------- 2 files changed, 20 deletions(-) diff --git a/src/senaite/core/datamanagers/field/sample_analyses.py b/src/senaite/core/datamanagers/field/sample_analyses.py index 3cb0f0b5f7..edb43297c2 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) @@ -343,14 +342,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 9472b46bff..18810d4b36 100644 --- a/src/senaite/core/tests/doctests/ARAnalysesFieldWithPartitions.rst +++ b/src/senaite/core/tests/doctests/ARAnalysesFieldWithPartitions.rst @@ -189,17 +189,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 .............................................. From 0447fdfb70c75c871e1bbb3857fd2cb859a93960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Mon, 29 Jul 2024 11:20:37 +0200 Subject: [PATCH 3/4] Changelog --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index a4c2b99545..989ce15226 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 - #2593 Always do a full reindex of the object after transition - #2593 Retrieve and store object's raw data on snapshot creation - #2593 Skip permissions update after transition when InternalUse is unchanged From ebfbb9c352a4c0f173e8f1c30a5e645c570824c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Mon, 29 Jul 2024 11:39:14 +0200 Subject: [PATCH 4/4] Fix doctest --- .../doctests/ARAnalysesFieldWithPartitions.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/senaite/core/tests/doctests/ARAnalysesFieldWithPartitions.rst b/src/senaite/core/tests/doctests/ARAnalysesFieldWithPartitions.rst index 18810d4b36..413171bc08 100644 --- a/src/senaite/core/tests/doctests/ARAnalysesFieldWithPartitions.rst +++ b/src/senaite/core/tests/doctests/ARAnalysesFieldWithPartitions.rst @@ -306,18 +306,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])