Commit 268d6078 authored by Rafael Monnerat's avatar Rafael Monnerat

Added new property at RelationFields and MultiRelationField.

Now is possible to define a set of listboxes that will used in dialog mode. This allow the user chooser (if len > 1) which listbox columns/search, he prefer use to find a certain object.

The approach is diferent of relation_form and define columns but still compatible with previous implementation. If the [multi]relation fields are not updated, be previous behaviour will still working.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22688 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent de97d3e6
...@@ -62,9 +62,10 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, ...@@ -62,9 +62,10 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget,
local_property_names = ['update_method', 'jump_method', 'allow_jump', local_property_names = ['update_method', 'jump_method', 'allow_jump',
'base_category', 'portal_type', 'allow_creation', 'base_category', 'portal_type', 'allow_creation',
'container_getter_id', 'catalog_index', 'container_getter_id', 'catalog_index',
'relation_setter_id', 'relation_form_id', 'columns', 'sort', 'relation_setter_id', 'relation_form_id', 'columns',
'parameter_list','list_method', 'sort', 'parameter_list','list_method',
'first_item', 'items', 'size', 'extra_item', 'first_item', 'items', 'proxy_listbox_ids',
'size', 'extra_item',
] ]
property_names = Widget.LinesTextAreaWidget.property_names + \ property_names = Widget.LinesTextAreaWidget.property_names + \
...@@ -180,6 +181,12 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, ...@@ -180,6 +181,12 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget,
default='', default='',
required=0) required=0)
proxy_listbox_ids = fields.ListTextAreaField('proxy_listbox_ids',
title='Proxy Listbox IDs',
description=('A list of listbox that can be used as proxy'),
default='',
required=0)
# delete double in order to keep a usable ZMI... # delete double in order to keep a usable ZMI...
# XXX need to keep order ! # XXX need to keep order !
#property_names = dict([(i,0) for i in property_names]).keys() #property_names = dict([(i,0) for i in property_names]).keys()
......
...@@ -1072,7 +1072,8 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -1072,7 +1072,8 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
# Field found # Field found
field_key = field.generate_field_key() field_key = field.generate_field_key()
field_value = REQUEST.form[field_key] field_value = REQUEST.form[field_key]
dialog_id = field.get_value('relation_form_id') or 'Base_viewRelatedObjectList' dialog_id = field.get_value('relation_form_id') or \
'Base_viewRelatedObjectList'
redirect_form = getattr(o, dialog_id) redirect_form = getattr(o, dialog_id)
# XXX Hardcoded listbox field # XXX Hardcoded listbox field
selection_name = redirect_form.listbox.get_value('selection_name') selection_name = redirect_form.listbox.get_value('selection_name')
...@@ -1108,6 +1109,8 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -1108,6 +1109,8 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
field_value = '' field_value = ''
if len(field_value) == 1: if len(field_value) == 1:
field_value = field_value[0] field_value = field_value[0]
if len(field_value) > 1 and isinstance(field_value, type([])):
field_value = ' OR '.join(field_value)
REQUEST.form[field_key] = field_value REQUEST.form[field_key] = field_value
portal_status_message = Message( portal_status_message = Message(
domain='erp5_ui', domain='erp5_ui',
...@@ -1143,6 +1146,14 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -1143,6 +1146,14 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
kw['portal_status_message'] = portal_status_message kw['portal_status_message'] = portal_status_message
kw['saved_form_data'] = saved_form_data kw['saved_form_data'] = saved_form_data
proxy_listbox_ids = field.get_value('proxy_listbox_ids')
REQUEST.set('proxy_listbox_ids', proxy_listbox_ids)
if len(proxy_listbox_ids) > 0:
REQUEST.set('proxy_listbox_id', proxy_listbox_ids[0][0])
else:
REQUEST.set('proxy_listbox_id', \
"Base_viewRelatedObjectListBase/listbox")
# Empty the selection (uid) # Empty the selection (uid)
REQUEST.form = kw # New request form REQUEST.form = kw # New request form
# Define new HTTP_REFERER # Define new HTTP_REFERER
......
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