diff --git a/product/ERP5Form/MultiRelationField.py b/product/ERP5Form/MultiRelationField.py index 0e0251fb590735b747d27b8b17eaee7eb76cccf4..1379bfd742794d35fb365c51d76b7c47c02208a3 100755 --- a/product/ERP5Form/MultiRelationField.py +++ b/product/ERP5Form/MultiRelationField.py @@ -158,6 +158,10 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, RelationField.R else: # no modification made, we can display only a lines text area widget html_string += Widget.LinesTextAreaWidget.render(self, field, key, value_list, REQUEST) + + html_string += ' <input type="image" src="%s/images/exec16.png" value="update..." name="%s/portal_selections/viewSearchRelatedDocumentDialog%s:method">' \ + % (portal_url_string, portal_object.getPath(), field.aq_parent._v_relation_field_index) + if value_list not in ((), [], None, ['']) and value_list == field.get_value('default'): if REQUEST.get('selection_name') is not None: html_string += ' <a href="%s?field_id=%s&form_id=%s&selection_name=%s&selection_index=%s"><img src="%s/images/jump.png"></a>' \ @@ -334,6 +338,8 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator, RelationField else: + relation_field_id = 'relation_%s' % ( key ) + # We must be able to erase the relation if value_list == ['']: display_text = 'Delete the relation' @@ -341,8 +347,37 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator, RelationField # return RelationEditor(key, base_category, portal_type, None, # portal_type_item, catalog_index, value, relation_setter_id, display_text) # Will be interpreted by Base_edit as "delete relation" (with no uid and value = '') + + if REQUEST.has_key( relation_field_id ): + # user click on the wheel: get the selection, and store the relation + if value_list == ['%']: + # we must know if user validate the form or click on the wheel button + relation_uid_list = REQUEST.get(relation_field_id, None) + if relation_uid_list != None: + relation_editor_list = [] + for i in range( len(relation_uid_list) ): + + relation_item_id = 'item_%s_%s' % ( key, i ) + relation_uid = relation_uid_list[i] + + related_object = portal_catalog.getObject(relation_uid) + if related_object is not None: + display_text = str(related_object.getProperty(catalog_index)) + else: + display_text = 'Object has been deleted' + # Check + REQUEST.set(relation_item_id, ( (display_text, relation_uid), )) + relation_editor_list.append( (i, '%', str(relation_uid), display_text) ) + + return MultiRelationEditor(field.id, base_category, portal_type, portal_type_item, catalog_index, relation_setter_id, relation_editor_list) + else: + # value must be define to ['%'] to see all objects in listbox + raise + else: + # User validate the form + relation_editor_list = [] raising_error_needed = 0 raising_error_value = ''