diff --git a/product/ERP5Form/MultiRelationField.py b/product/ERP5Form/MultiRelationField.py index c4d2bcbdc0232eed2d58cdf4b6869edac9b368b2..d8b30090c5c85f842e042df80cac0aa9f76a311e 100644 --- a/product/ERP5Form/MultiRelationField.py +++ b/product/ERP5Form/MultiRelationField.py @@ -46,6 +46,7 @@ NEW_CONTENT_PREFIX = '_newContent_' # Key for sub listfield SUB_FIELD_ID = 'relation' ITEM_ID = 'item' +NO_VALUE = '??? (No Value)' def checkSameKeys(a , b): """ @@ -208,6 +209,12 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, if isinstance(value_list, StringType): # Value is a string, reformat it correctly value_list = value_list.split("\n") + else: + # We get a list + # rather than displaying nothing, display a marker when the + # property is not set + # XXX Translate ? + value_list = [(x or NO_VALUE) for x in value_list] # Check all relation for i in range(len(value_list)): ################################### @@ -224,11 +231,6 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, if (relation_item_list is not None) and \ (value != ''): need_validation = 1 - if value is None : - # rather than displaying nothing, display a marker when the - # property is not set - # XXX Translate ? - value = '??? (no value)' # If we get a empty string, display nothing ! if value != '': result_list.append((Widget.TextWidgetInstance, relation_field_id, @@ -565,7 +567,6 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): if (found == 1) and \ (value != display_text): relation_editor_list = None -# import pdb; pdb.set_trace() need_to_revalidate = 1 REQUEST.set(relation_field_id, None) break diff --git a/product/ERP5Form/RelationField.py b/product/ERP5Form/RelationField.py index 86ce53074f7c41074528506fb825002c5ab0f243..ee1d10332fe3804706b818cfb00cfce58851f16f 100644 --- a/product/ERP5Form/RelationField.py +++ b/product/ERP5Form/RelationField.py @@ -37,7 +37,8 @@ from Products.ERP5Type.Message import Message from Products.ERP5Form import MultiRelationField from Products.ERP5Form.MultiRelationField import MAX_SELECT, \ NEW_CONTENT_PREFIX, \ - SUB_FIELD_ID, ITEM_ID + SUB_FIELD_ID, ITEM_ID, \ + NO_VALUE from types import StringType from AccessControl import ClassSecurityInfo from zLOG import LOG @@ -56,6 +57,7 @@ class RelationStringFieldWidget( default_widget_rendering_instance = Widget.TextWidgetInstance def _generateRenderValueList(self, field, key, value, REQUEST): +# value = value or NO_VALUE relation_field_id = field.generate_subfield_key(SUB_FIELD_ID, key=key) relation_item_key = field.generate_subfield_key(ITEM_ID, key=key) relation_item_list = REQUEST.get(relation_item_key, []) @@ -75,13 +77,17 @@ class RelationEditor(MultiRelationField.MultiRelationEditor): allow_class(RelationEditor) class RelationStringFieldValidator( - MultiRelationField.MultiRelationStringFieldValidator): + MultiRelationField.MultiRelationStringFieldValidator, + Validator.StringValidator): """ Validation includes lookup of relared instances """ message_names = Validator.StringValidator.message_names + \ MultiRelationField.MultiRelationStringFieldValidator.message_names + property_names = Validator.StringValidator.property_names + \ + MultiRelationField.MultiRelationStringFieldValidator.property_names + # Delete double in order to keep a usable ZMI... # Need to keep order ! _v_dict = {} @@ -92,6 +98,14 @@ class RelationStringFieldValidator( _v_dict[message_name] = 1 message_names = _v_message_name_list + _v_dict = {} + _v_property_name_list = [] + for property_name in property_names: + if not _v_dict.has_key(property_name): + _v_property_name_list.append(property_name) + _v_dict[property_name] = 1 + property_names = _v_property_name_list + # Relation field variable editor = RelationEditor default_validator_instance = Validator.StringValidatorInstance