Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError: "Can't pickle objects in acquisition wrappers" (Calculation) #340

Merged
merged 3 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bika/lims/browser/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bika/lims/catalog/analysis_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
'getClientURL',
'getAnalysisRequestTitle',
'getResult',
'getCalculation',
'getCalculationUID',
'getUnit',
'getKeyword',
'getCategoryTitle',
Expand Down
2 changes: 1 addition & 1 deletion bika/lims/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
<version>1.1.0</version>
<version>1.1.2</version>
<dependencies>
Copy link
Contributor

@ramonski ramonski Nov 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the jump directly to 1.1.2 and not 1.1.1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed to set the metadata's version to 1.1.1 in my previous upgradestep :(

<dependency>profile-jarn.jsi18n:default</dependency>
<dependency>profile-Products.ATExtensions:default</dependency>
Expand Down
6 changes: 6 additions & 0 deletions bika/lims/upgrade/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@
handler="bika.lims.upgrade.v01_01_001.upgrade"
profile="bika.lims:default"/>

<genericsetup:upgradeStep
title="Upgrade to Bika LIMS Evo 1.1.2"
source="1.1.1"
destination="1.1.2"
handler="bika.lims.upgrade.v01_01_002.upgrade"
profile="bika.lims:default"/>
</configure>
40 changes: 40 additions & 0 deletions bika/lims/upgrade/v01_01_002.py
Original file line number Diff line number Diff line change
@@ -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