diff --git a/CHANGES.rst b/CHANGES.rst index ebd9471468..5f1d531ac6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,7 @@ Changelog 2.3.0 (unreleased) ------------------ +- #2148 Performance: prioritize raw getter for AllowedInstruments field - #2147 Remove stale function workflow.getReviewHistory - #2146 Fix "No object found for UID: " in report preview - #2145 Crop page navigation for DX reference widget diff --git a/src/bika/lims/browser/analyses/view.py b/src/bika/lims/browser/analyses/view.py index 944a209d43..df67e9e393 100644 --- a/src/bika/lims/browser/analyses/view.py +++ b/src/bika/lims/browser/analyses/view.py @@ -1532,13 +1532,13 @@ def is_instrument_required(self, analysis): # If method selection list is required, the instrument selection too if self.is_method_required(analysis): return True - + # Always return true if the analysis has an instrument assigned - if self.get_instrument(analysis): + analysis = self.get_object(analysis) + if analysis.getRawInstrument(): return True - obj = self.get_object(analysis) - instruments = obj.getAllowedInstruments() + instruments = analysis.getRawAllowedInstruments() # There is no need to check for the instruments of the method assigned # to # the analysis (if any), because the instruments rendered in the # selection list are always a subset of the allowed instruments when diff --git a/src/bika/lims/content/abstractanalysis.py b/src/bika/lims/content/abstractanalysis.py index 848c8fba6b..b6b5ea6034 100644 --- a/src/bika/lims/content/abstractanalysis.py +++ b/src/bika/lims/content/abstractanalysis.py @@ -728,7 +728,7 @@ def isInstrumentAllowed(self, instrument): :rtype: bool """ uid = api.get_uid(instrument) - return uid in map(api.get_uid, self.getAllowedInstruments()) + return uid in self.getRawAllowedInstruments() @security.public def isMethodAllowed(self, method): @@ -768,6 +768,15 @@ def getAllowedInstruments(self): return [] return service.getInstruments() + @security.public + def getRawAllowedInstruments(self): + """Returns the UIDS of the allowed instruments from the service + """ + service = self.getAnalysisService() + if not service: + return [] + return service.getRawInstruments() + @security.public def getExponentialFormatPrecision(self, result=None): """ Returns the precision for the Analysis Service and result diff --git a/src/bika/lims/content/abstractbaseanalysis.py b/src/bika/lims/content/abstractbaseanalysis.py index 44b314185b..cd2cf386f8 100644 --- a/src/bika/lims/content/abstractbaseanalysis.py +++ b/src/bika/lims/content/abstractbaseanalysis.py @@ -963,11 +963,7 @@ def getRawInstrument(self): :returns: Instrument UID """ - field = self.getField("Instrument") - instrument = field.getRaw(self) - if not instrument: - return None - return instrument + return self.getField("Instrument").getRaw(self) @security.public def getInstrumentUID(self):