diff --git a/CHANGES.rst b/CHANGES.rst index 831433695c..c69713894b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -25,7 +25,8 @@ Changelog **Fixed** -- #330 Show action buttons when shorting by column in listings +- #340 Fix TypeError: "Can't pickle objects in acquisition wrappers" (Calculation) +- #330 Show action buttons when sorting by column in listings - #280 Integration of PR-2271. Setting 2 or more CCContacts in AR view produces a Traceback on Save - #281 Integration of PR-2269. Show the Unit in Manage Analyses View - #282 Integration of PR-2252. Traceback if the title contains braces on content creation diff --git a/bika/lims/browser/analyses.py b/bika/lims/browser/analyses.py index e983a25316..0aa40f2ad0 100644 --- a/bika/lims/browser/analyses.py +++ b/bika/lims/browser/analyses.py @@ -459,7 +459,7 @@ def folderitem(self, obj, item, index): item['class']['retested'] = 'center' item['result_captured'] = self.ulocalized_time( obj.getResultCaptureDate, long_format=0) - item['calculation'] = obj.getCalculation and True or False + item['calculation'] = obj.getCalculationUID and True or False if obj.meta_type == "ReferenceAnalysis": item['DueDate'] = self.ulocalized_time( obj.getExpiryDate, long_format=0) diff --git a/bika/lims/catalog/analysis_catalog.py b/bika/lims/catalog/analysis_catalog.py index 193ba16b2b..9985638f2b 100644 --- a/bika/lims/catalog/analysis_catalog.py +++ b/bika/lims/catalog/analysis_catalog.py @@ -69,7 +69,7 @@ 'getClientURL', 'getAnalysisRequestTitle', 'getResult', - 'getCalculation', + 'getCalculationUID', 'getUnit', 'getKeyword', 'getCategoryTitle', diff --git a/bika/lims/profiles/default/metadata.xml b/bika/lims/profiles/default/metadata.xml index c4a25b1709..71aaa8c36e 100644 --- a/bika/lims/profiles/default/metadata.xml +++ b/bika/lims/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 1.1.0 + 1.1.2 profile-jarn.jsi18n:default profile-Products.ATExtensions:default diff --git a/bika/lims/upgrade/configure.zcml b/bika/lims/upgrade/configure.zcml index 85c5e43410..f4fb878935 100644 --- a/bika/lims/upgrade/configure.zcml +++ b/bika/lims/upgrade/configure.zcml @@ -31,4 +31,10 @@ handler="bika.lims.upgrade.v01_01_001.upgrade" profile="bika.lims:default"/> + diff --git a/bika/lims/upgrade/v01_01_002.py b/bika/lims/upgrade/v01_01_002.py new file mode 100644 index 0000000000..b9f70dc5dd --- /dev/null +++ b/bika/lims/upgrade/v01_01_002.py @@ -0,0 +1,40 @@ +from Acquisition import aq_inner +from Acquisition import aq_parent +from bika.lims import logger +from bika.lims.catalog import CATALOG_ANALYSIS_LISTING +from bika.lims.config import PROJECTNAME as product +from bika.lims.upgrade import upgradestep +from bika.lims.upgrade.utils import UpgradeUtils + +version = '1.1.2' +profile = 'profile-{0}:default'.format(product) + + +@upgradestep(product, version) +def upgrade(tool): + portal = aq_parent(aq_inner(tool)) + setup = portal.portal_setup + ut = UpgradeUtils(portal) + ver_from = ut.getInstalledVersion(product) + + if ut.isOlderVersion(product, version): + logger.info("Skipping upgrade of {0}: {1} > {2}".format( + product, ver_from, version)) + # The currently installed version is more recent than the target + # version of this upgradestep + return True + + logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) + + # The assignment of the whole Calculation object in a metadata column + # was causing a "TypeError: Can't pickle objects in acquisition wrappers". + # getCalculation was only used in analyses listing and can be safely + # replaced by getCalculationUID, cause is only used to determine if a + # calculation is required to compute the result value + # https://github.com/senaite/bika.lims/issues/322 + ut.delColumn(CATALOG_ANALYSIS_LISTING, 'getCalculation') + ut.addColumn(CATALOG_ANALYSIS_LISTING, 'getCalculationUID') + ut.refreshCatalogs() + + logger.info("{0} upgraded to version {1}".format(product, version)) + return True