Commit afa5c0fc authored by Jérome Perrin's avatar Jérome Perrin

core: keep using default_params from proxy listbox ids

With bf57228a ([erp5_core] RelationField listbox must also fetch
default_params value from the relationfield, 2018-05-09), we introduced a
regression that listboxs from relation fields "proxy listbox ids" default params
where no longer used. As a result, if we have a listbox which define some
catalog search with default parameters, like for example the "Suppliers" or
"Clients" listboxs from erp5_trade are doing, these parameters were not
taken into account. In the case of trade listbox, this was showing all nodes.

This changes Base_getRelatedObjectParameter to get catalog search from the
proxy listbox if there is one.
parent f67f5346
Pipeline #16075 failed with stage
in 0 seconds
# This script is used in order to retrieve parameter in the listbox Displayed
# by Base_viewRelatedObjectList from the relation field
result = None
# This dialog can either display a generic listbox (Base_viewRelatedObjectList/listbox)
# that takes its configuration dynamically from the relation field configuration, or
# display listbox from "Proxy Listbox IDs".
# When using a listbox from "Proxy Listbox IDs", that listbox defines the configuration
# and have priority over the relation field configuration.
result = None
request = context.REQUEST
if parameter is not None:
......@@ -11,9 +17,18 @@ if parameter is not None:
form_id = request.get('original_form_id',None) \
or request.get('field_your_original_form_id', None) \
or request.get('form_id')
listbox = getattr(context, form_id).get_field(field_id)
dialog_id = listbox.get_value('relation_form_id') or 'Base_viewRelatedObjectList'
result = listbox.get_value(parameter)
relation_field = getattr(context, form_id).get_field(field_id)
dialog_id = relation_field.get_value('relation_form_id') or 'Base_viewRelatedObjectList'
# the listbox from "proxy listbox id"
proxied_listbox = None
relation_field_proxy_listbox = context.Base_getRelationFieldProxyListBoxId()
if relation_field_proxy_listbox != \
'Base_viewRelatedObjectListBase/listbox':
proxied_listbox = context.restrictedTraverse(
relation_field_proxy_listbox, None)
result = relation_field.get_value(parameter)
if result in [ [], (), None, '']:
if parameter == 'proxy_listbox_ids':
......@@ -21,17 +36,15 @@ if parameter is not None:
if parameter != 'parameter_list':
result = getattr(context, dialog_id, None).get_field( 'listbox' ).get_orig_value(parameter)
if parameter == 'parameter_list':
if proxied_listbox is None:
return result
return proxied_listbox.get_value('default_params')
if parameter == 'portal_type':
portal_type = listbox.get_value('portal_type')
proxied_listbox = None
relation_field_proxy_listbox = context.Base_getRelationFieldProxyListBoxId()
if relation_field_proxy_listbox != \
'Base_viewRelatedObjectListBase/listbox':
proxied_listbox = context.restrictedTraverse(
relation_field_proxy_listbox, None)
portal_type = relation_field.get_value('portal_type')
if proxied_listbox is None:
return portal_type
proxied_listbox_portal_type = proxied_listbox.get_value('portal_types')
portal_type_first_item_list = [x[0] for x in portal_type]
return [x for x in proxied_listbox_portal_type if x[0] in portal_type_first_item_list] or portal_type
......
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