diff --git a/CHANGES.rst b/CHANGES.rst index 38e72cc4d3..4b69f14930 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 diff --git a/bika/lims/utils/analysis.py b/bika/lims/utils/analysis.py index c7a70ab8f2..e8fac40109 100644 --- a/bika/lims/utils/analysis.py +++ b/bika/lims/utils/analysis.py @@ -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 @@ -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):