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 when retracting analysis with ExtendedField #1556

Merged
merged 1 commit into from
Mar 1, 2020
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
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Changelog

**Fixed**

- #1556 Fix TypeError when retracting analyses with ExtendedField
- #1552 Rejection on registration is neither generating rejection pdf nor email
- #1550 Fix Uncaught TypeError in combogrid
- #1542 Fix sporadical errors when contacts do not have a valid email address
Expand Down
13 changes: 10 additions & 3 deletions bika/lims/utils/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from Products.Archetypes.event import ObjectInitializedEvent
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import _createObjectByType
from archetypes.schemaextender.interfaces import IExtensionField

from bika.lims import bikaMessageFactory as _
from bika.lims.interfaces import IAnalysisService
from bika.lims.utils import formatDecimalMark
Expand Down Expand Up @@ -74,9 +76,14 @@ def copy_analysis_field_values(source, analysis, **kwargs):
# to give the value. We have realized that in some cases using
# 'set' when the value is a string, it saves the value
# as unicode instead of plain string.
mutator_name = analysis.getField(fieldname).mutator
mutator = getattr(analysis, mutator_name)
mutator(value)
field = analysis.getField(fieldname)
if IExtensionField.providedBy(field):
# SchemaExtender fields don't auto-generate the accessor/mutator
field.set(analysis, value)
else:
mutator_name = field.mutator
mutator = getattr(analysis, mutator_name)
mutator(value)


def create_analysis(context, source, **kwargs):
Expand Down