diff --git a/src/senaite/core/content/analysisprofile.py b/src/senaite/core/content/analysisprofile.py index 2b554563a9..09a3f1169e 100644 --- a/src/senaite/core/content/analysisprofile.py +++ b/src/senaite/core/content/analysisprofile.py @@ -260,12 +260,11 @@ def getServices(self, active_only=True): :returns: List of analysis service objects """ - services = [] - for uid in self.getServiceUIDs(): - obj = api.get_object(uid) - if not active_only or api.is_active(obj): - services.append(obj) - return services + services = map(api.get_object, self.getServiceUIDs()) + if active_only: + # filter out inactive services + services = filter(api.is_active, services) + return list(services) @security.protected(permissions.ModifyPortalContent) def setServices(self, value): diff --git a/src/senaite/core/content/sampletemplate.py b/src/senaite/core/content/sampletemplate.py index eeab13b1df..2116cad351 100644 --- a/src/senaite/core/content/sampletemplate.py +++ b/src/senaite/core/content/sampletemplate.py @@ -461,12 +461,11 @@ def getServices(self, active_only=True): :returns: List of analysis service objects """ - services = [] - for uid in self.getServiceUIDs(): - obj = api.get_object(uid) - if not active_only or api.is_active(obj): - services.append(obj) - return services + services = map(api.get_object, self.getServiceUIDs()) + if active_only: + # filter out inactive services + services = filter(api.is_active, services) + return list(services) @security.protected(permissions.ModifyPortalContent) def setServices(self, value):