diff --git a/bika/lims/browser/js/bika.lims.analysisrequest.add_by_col.js b/bika/lims/browser/js/bika.lims.analysisrequest.add_by_col.js index 770f82abd2..17c1fb0535 100644 --- a/bika/lims/browser/js/bika.lims.analysisrequest.add_by_col.js +++ b/bika/lims/browser/js/bika.lims.analysisrequest.add_by_col.js @@ -1773,10 +1773,11 @@ function AnalysisRequestAddByCol() { // Expand category var service = service_data[si] services.push(service) - var th = $("table[form_id='" + service['PointOfCapture'] + "'] " + - "th[cat='" + service['CategoryTitle'] + "']") - if(expanded_categories.indexOf(th) < 0) { - expanded_categories.push(th) + var th_key = "table[form_id='" + service['PointOfCapture'] + "'] " + + "th[cat='" + service['CategoryTitle'] + "']" + var th = $(th_key) + if(expanded_categories.indexOf(th_key) < 0) { + expanded_categories.push(th_key) var def = $.Deferred() def = category_header_expand_handler(th) defs.push(def) diff --git a/bika/lims/content/analysisrequest.py b/bika/lims/content/analysisrequest.py index 45cfafc8c4..ec0bee0c35 100644 --- a/bika/lims/content/analysisrequest.py +++ b/bika/lims/content/analysisrequest.py @@ -313,13 +313,6 @@ showOn=True, ), ), - ComputedField( - 'BatchUID', - expression='here.getBatch().UID() if here.getBatch() else ""', - widget=ComputedWidget( - visible=False, - ), - ), ReferenceField( 'SamplingRound', allowed_types=('SamplingRound',), @@ -1861,6 +1854,7 @@ def getProvince(self): client = self.aq_parent return client.getProvince() + @security.public def getBatch(self): # The parent type may be "Batch" during ar_add. # This function fills the hidden field in ar_add.pt @@ -1869,6 +1863,19 @@ def getBatch(self): else: return self.Schema()['Batch'].get(self) + @security.public + def getBatchUID(self): + batch = self.getBatch() + if batch: + return batch.UID() + + @security.public + def setBatch(self, value=None): + original_value = self.Schema().getField('Batch').get(self) + if original_value != value: + self.Schema().getField('Batch').set(self, value) + self._reindexAnalyses(['getBatchUID'], False) + def getDefaultMemberDiscount(self): """ compute default member discount if it applies """ if hasattr(self, 'getMemberDiscountApplies'): @@ -2985,8 +2992,10 @@ def getPrioritySortkey(self): def setPriority(self, value): if not value: value = self.Schema().getField('Priority').getDefault(self) - self.Schema().getField('Priority').set(self, value) - self._reindexAnalyses(['getPrioritySortkey'], True) + original_value = self.Schema().getField('Priority').get(self) + if original_value != value: + self.Schema().getField('Priority').set(self, value) + self._reindexAnalyses(['getPrioritySortkey'], True) @security.private def _reindexAnalyses(self, idxs=None, update_metadata=False): diff --git a/bika/lims/subscribers/objectmodified.py b/bika/lims/subscribers/objectmodified.py index 26d6e20286..622e675c7c 100644 --- a/bika/lims/subscribers/objectmodified.py +++ b/bika/lims/subscribers/objectmodified.py @@ -66,15 +66,3 @@ def ObjectModifiedEventHandler(obj, event): brains = cat(portal_type=i[0], getCategoryUID=obj.UID()) for brain in brains: brain.getObject().reindexObject(idxs=['getCategoryTitle']) - # TODO: This is a workaround in order to reindex the getBatchUID index - # of analyses when the analysis request has been modified. When the - # ReferenceField 'batch' is modified (and because it is reference field) - # only the archetype 'Reference' object is flagged as modified, not - # the whole AnalysisRequest. We need to migrate that reference field - # to the new ones. - # For now, we will take advantage of that reference object and we will - # reindex only the getbatchUID. - elif IAnalysisRequest.providedBy(obj.aq_parent.aq_inner): - analyses = obj.getAnalyses() - for analysis in analyses: - analysis.getObject().reindexObject(idxs=['getBatchUID']) diff --git a/bika/lims/workflow/__init__.py b/bika/lims/workflow/__init__.py index bc923e85e4..e6954e65d3 100644 --- a/bika/lims/workflow/__init__.py +++ b/bika/lims/workflow/__init__.py @@ -84,11 +84,11 @@ def doActionFor(instance, action_id, active_only=True, allowed_transition=True): workflow = getToolByName(instance, "portal_workflow") skipaction = skip(instance, action_id, peek=True) if skipaction: - clazzname = instance.__class__.__name__ - msg = "Skipping transition '{0}': {1} '{2}'".format(action_id, - clazzname, - instance.getId()) - logger.info(msg) + #clazzname = instance.__class__.__name__ + #msg = "Skipping transition '{0}': {1} '{2}'".format(action_id, + # clazzname, + # instance.getId()) + #logger.info(msg) return actionperformed, message if allowed_transition: @@ -319,11 +319,8 @@ def wasTransitionPerformed(instance, transition_id): """Checks if the transition has already been performed to the object Instance's workflow history is checked. """ - review_history = getReviewHistory(instance) - for event in review_history: - if event['action'] == transition_id: - return True - return False + transitions = getReviewHistoryActionsList(instance) + return transition_id in transitions def isActive(instance):