From e23281db167e04b4f857be9a2582939cde8ffe44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Thu, 12 Dec 2024 23:41:25 +0100 Subject: [PATCH] Skip analyses in a detached status in guard_ship --- src/senaite/referral/adapters/guards/sample.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/senaite/referral/adapters/guards/sample.py b/src/senaite/referral/adapters/guards/sample.py index ee61968..1e54a59 100644 --- a/src/senaite/referral/adapters/guards/sample.py +++ b/src/senaite/referral/adapters/guards/sample.py @@ -42,9 +42,16 @@ def guard_ship(self): all analyses from the sample are in unassigned status """ allowed = ["unassigned"] - analyses = self.context.getAnalyses(full_objects=True) - valid = map(lambda an: api.get_review_status(an) in allowed, analyses) - return all(valid) + detached = ["cancelled", "rejected", "retracted"] + for analysis in self.context.getAnalyses(full_objects=True): + status = api.get_review_status(analysis) + if status in detached: + # skip analyses in detached status + continue + if status not in allowed: + # all analyses must be in "unassigned" status + return False + return True def guard_reject_at_reference(self): """Returns true if the sample can be transitioned to rejected at