From 74dfff207a0c2c6d6ecdfc0fbc3a962ee86843fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Wed, 27 Nov 2024 10:33:20 +0100 Subject: [PATCH] Fix analysis instrument is not auto-assigned on change in worksheet (#2647) * Instrument is not assigned to analyses when set in worksheet * Changelog --- CHANGES.rst | 1 + src/bika/lims/browser/worksheet/ajax.py | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index d8d2de51d9..d65dd2f45e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,7 @@ Changelog 2.6.0 (unreleased) ------------------ +- #2647 Fix analysis instrument is not auto-assigned on change in worksheet - #2643 Improve performance of analysis verification - #2645 Tabbed content view - #2624 Added "Maximum holding time" setting to services and analyses diff --git a/src/bika/lims/browser/worksheet/ajax.py b/src/bika/lims/browser/worksheet/ajax.py index 10ddd96435..f6984fbc5c 100644 --- a/src/bika/lims/browser/worksheet/ajax.py +++ b/src/bika/lims/browser/worksheet/ajax.py @@ -20,7 +20,8 @@ import plone import plone.protect -from Products.Archetypes.config import REFERENCE_CATALOG + +from bika.lims import api from Products.CMFCore.utils import getToolByName from Products.Five.browser import BrowserView @@ -54,13 +55,15 @@ def __init__(self, context, request): self.request = request def __call__(self): - rc = getToolByName(self.context, REFERENCE_CATALOG) plone.protect.CheckAuthenticator(self.request) plone.protect.PostOnly(self.request) value = self.request.get('value', '') if not value: raise Exception("Invalid instrument") - instrument = rc.lookupObject(value) + + instrument = api.get_object_by_uid(value, None) if not instrument: raise Exception("Unable to lookup instrument") - self.context.setInstrument(instrument) + + # set the instrument to the worksheet and analyses + self.context.setInstrument(instrument, override_analyses=True)