Commit 9efafb3b authored by Romain Courteaud's avatar Romain Courteaud

Use setValue when the relation has only one value.

Add a blank line in the popup menu (if we don't want to create a new object).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7054 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f0519aa1
......@@ -449,6 +449,12 @@ class MultiRelationEditor:
portal_type=self.portal_type_list)
else:
# we could call a generic method which create the setter method name
if len(relation_object_list) == 1:
set_method_name = '_set%sValue' % \
convertToUpperCase(self.base_category)
getattr(o, set_method_name)(relation_object_list[0],
portal_type=self.portal_type_list)
else:
set_method_name = '_set%sValueList' % \
convertToUpperCase(self.base_category)
getattr(o, set_method_name)(relation_object_list,
......@@ -534,7 +540,7 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator):
# User clicked on the wheel
####################################
need_to_revalidate = 1
if relation_uid_list is not None:
if relation_uid_list not in (None, ''):
need_to_revalidate = 0
relation_editor_list = []
for relation_item_id, relation_uid, value in \
......@@ -717,6 +723,8 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator):
# relation_editor_list.append((0, value, relation_uid,
# display_text, None, None))
elif len(relation_list) == 0:
# Add blank line
menu_item_list.append(('', ''))
# If the length is 0, raise an error
if field.get_value('allow_creation') == 1 :
# XXX
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment