Commit 083d1aee authored by Jérome Perrin's avatar Jérome Perrin

Repair proxy listbox ids defining parameters (like "Suppliers" or "Clients")

See merge request nexedi/erp5!1439
parents 7479fa63 afa5c0fc
Pipeline #16063 failed with stage
in 0 seconds
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testRelationFieldProxyListboxId</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html>
<head><title>Test Proxy Listbox Ids on relation fields.</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="4">
Test Proxy Listbox Ids on relation fields.
</td></tr>
</thead>
<tbody tal:define="init_method string:Zuite_createSaleOrderForTradeZuite;">
<!-- Setup {{{ -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForTradeZuite/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/sale_order_module/erp5_trade_ui_test_sale_order_1?editable=true</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<!-- }}} -->
<tr>
<td>type</td>
<td>//input[@name='field_my_source_title']</td>
<td>%</td>
</tr>
<tr>
<td>fireEvent</td>
<td>//input[@name='field_my_source_title']</td>
<td>input</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//li[@data-explore="true"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//li[@data-explore="true"]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_pt_form_list.html']//input[@name="search"]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>proxy_form_id_list</td>
<td></td>
</tr>
<tr>
<td>assertSelected</td>
<td>proxy_form_id_list</td>
<td>All</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block tal:repeat="node_title python: ('Organisation supplier', 'Organisation client', 'Person supplier', 'Person client')">
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope="field_listbox"]//tbody/tr/td[1]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tr>
<td>select</td>
<td>proxy_form_id_list</td>
<td>Suppliers</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block tal:repeat="node_title python: ('Organisation supplier', 'Person supplier', )">
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope="field_listbox"]//tbody/tr/td[1]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:repeat="node_title python: ('Organisation client', 'Person client')">
<tr>
<td>assertElementNotPresent</td>
<td>//div[@data-gadget-scope="field_listbox"]//tbody/tr/td[1]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tr>
<td>select</td>
<td>proxy_form_id_list</td>
<td>Clients</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block tal:repeat="node_title python: ('Organisation client', 'Person client')">
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope="field_listbox"]//tbody/tr/td[1]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:repeat="node_title python: ('Organisation supplier', 'Person supplier', )">
<tr>
<td>assertElementNotPresent</td>
<td>//div[@data-gadget-scope="field_listbox"]//tbody/tr/td[1]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tr>
<td>select</td>
<td>proxy_form_id_list</td>
<td>Organisations</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block tal:repeat="node_title python: ('Organisation supplier', 'Organisation client', )">
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope="field_listbox"]//tbody/tr/td[1]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:repeat="node_title python: ('Person supplier', 'Person client')">
<tr>
<td>assertElementNotPresent</td>
<td>//div[@data-gadget-scope="field_listbox"]//tbody/tr/td[1]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tr>
<td>select</td>
<td>proxy_form_id_list</td>
<td>Persons</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block tal:repeat="node_title python: ('Person supplier', 'Person client')">
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope="field_listbox"]//tbody/tr/td[1]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:repeat="node_title python: ('Organisation supplier', 'Organisation client', )">
<tr>
<td>assertElementNotPresent</td>
<td>//div[@data-gadget-scope="field_listbox"]//tbody/tr/td[1]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
</tbody></table>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testRelationFieldProxyListboxId</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html>
<head><title>Test Proxy Listbox Ids on relation fields.</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="4">
Test Proxy Listbox Ids on relation fields.
</td></tr>
</thead>
<tbody tal:define="init_method string:Zuite_createSaleOrderForTradeZuite;">
<!-- Setup {{{ -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForTradeZuite/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/sale_order_module/erp5_trade_ui_test_sale_order_1</td>
<td></td>
</tr>
<!-- }}} -->
<tr>
<td>clickAndWait</td>
<td>//input[@name="field_my_source_title"]/../input[@alt="update..."]</td>
<td></td>
</tr>
<tr>
<td>assertSelected</td>
<td>select_dialog</td>
<td>All</td>
</tr>
<tr>
<td>assertTextNotPresent</td>
<td>Site Error</td>
<td></td>
</tr>
<tr>
<td>verifyPortalStatusMessage</td>
<td>Please select one object.</td>
<td></td>
</tr>
<tr>
<td>assertTextNotPresent</td>
<td>Site Error</td>
<td></td>
</tr>
<tal:block tal:repeat="node_title python: ('Organisation supplier', 'Organisation client', 'Person supplier', 'Person client')">
<tr>
<td>assertElementPresent</td>
<td>//table[contains(@class, "listbox")]//tr/td[2]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tr>
<td>selectAndWait</td>
<td>select_dialog</td>
<td>Suppliers</td>
</tr>
<tal:block tal:repeat="node_title python: ('Organisation supplier', 'Person supplier', )">
<tr>
<td>assertElementPresent</td>
<td>//table[contains(@class, "listbox")]//tr/td[2]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:repeat="node_title python: ('Organisation client', 'Person client')">
<tr>
<td>assertElementNotPresent</td>
<td>//table[contains(@class, "listbox")]//tr/td[2]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tr>
<td>selectAndWait</td>
<td>select_dialog</td>
<td>Clients</td>
</tr>
<tal:block tal:repeat="node_title python: ('Organisation client', 'Person client')">
<tr>
<td>assertElementPresent</td>
<td>//table[contains(@class, "listbox")]//tr/td[2]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:repeat="node_title python: ('Organisation supplier', 'Person supplier', )">
<tr>
<td>assertElementNotPresent</td>
<td>//table[contains(@class, "listbox")]//tr/td[2]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tr>
<td>selectAndWait</td>
<td>select_dialog</td>
<td>Organisations</td>
</tr>
<tal:block tal:repeat="node_title python: ('Organisation supplier', 'Organisation client', )">
<tr>
<td>assertElementPresent</td>
<td>//table[contains(@class, "listbox")]//tr/td[2]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:repeat="node_title python: ('Person supplier', 'Person client')">
<tr>
<td>assertElementNotPresent</td>
<td>//table[contains(@class, "listbox")]//tr/td[2]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tr>
<td>selectAndWait</td>
<td>select_dialog</td>
<td>Persons</td>
</tr>
<tal:block tal:repeat="node_title python: ('Person supplier', 'Person client')">
<tr>
<td>assertElementPresent</td>
<td>//table[contains(@class, "listbox")]//tr/td[2]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:repeat="node_title python: ('Organisation supplier', 'Organisation client', )">
<tr>
<td>assertElementNotPresent</td>
<td>//table[contains(@class, "listbox")]//tr/td[2]/a[text() = "<tal:block tal:replace="node_title"/>"]</td>
<td></td>
</tr>
</tal:block>
</tbody></table>
</body>
</html>
\ No newline at end of file
...@@ -4,6 +4,10 @@ object_value_list = [ ...@@ -4,6 +4,10 @@ object_value_list = [
getattr(portal.sale_order_module, 'erp5_trade_ui_test_sale_order_1', None), getattr(portal.sale_order_module, 'erp5_trade_ui_test_sale_order_1', None),
getattr(portal.organisation_module, 'erp5_trade_ui_test_organisation_1', None), getattr(portal.organisation_module, 'erp5_trade_ui_test_organisation_1', None),
getattr(portal.organisation_module, 'erp5_trade_ui_test_organisation_2', None), getattr(portal.organisation_module, 'erp5_trade_ui_test_organisation_2', None),
getattr(portal.organisation_module, 'test_trade_ui_test_supplier', None),
getattr(portal.organisation_module, 'test_trade_ui_test_client', None),
getattr(portal.person_module, 'test_trade_ui_test_supplier', None),
getattr(portal.person_module, 'test_trade_ui_test_client', None),
] + [ ] + [
getattr(portal.getDefaultModule(portal_type), "erp5_trade_ui_test_trade_condition" + suffix, None) getattr(portal.getDefaultModule(portal_type), "erp5_trade_ui_test_trade_condition" + suffix, None)
for portal_type in ("Internal Trade Condition", "Purchase Trade Condition", "Sale Trade Condition") for portal_type in ("Internal Trade Condition", "Purchase Trade Condition", "Sale Trade Condition")
......
portal = context.getPortalObject()
# Reset selections # Reset selections
selection_tool = context.getPortalObject().portal_selections selection_tool = portal.portal_selections
selection_tool.setSelectionFor('sale_order_selection', None) selection_tool.setSelectionFor('sale_order_selection', None)
# Create role categories
role_base_category = portal.restrictedTraverse('portal_categories/role')
for role_id, role_title in (
('client', 'Client'),
('supplier', 'Supplier')):
if role_base_category.get(role_id) is None:
role_base_category.newContent(
portal_type='Category',
id=role_id,
title=role_title
)
# Set system preferences
preference = portal.portal_preferences.getActiveSystemPreference()
preference.setPreferredClientRoleList(['role/client'])
preference.setPreferredSupplierRoleList(['role/supplier'])
# Create some nodes
for portal_type in ('Person', 'Organisation'):
for role in ('client', 'supplier'):
portal.getDefaultModule(portal_type).newContent(
id='test_trade_ui_test_' + role,
portal_type=portal_type,
title='%s %s' % (portal_type, role),
role_value=role_base_category[role],
).validate()
return "Reset Successfully." return "Reset Successfully."
# This script is used in order to retrieve parameter in the listbox Displayed # This script is used in order to retrieve parameter in the listbox Displayed
# by Base_viewRelatedObjectList from the relation field # 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 request = context.REQUEST
if parameter is not None: if parameter is not None:
...@@ -11,9 +17,18 @@ if parameter is not None: ...@@ -11,9 +17,18 @@ if parameter is not None:
form_id = request.get('original_form_id',None) \ form_id = request.get('original_form_id',None) \
or request.get('field_your_original_form_id', None) \ or request.get('field_your_original_form_id', None) \
or request.get('form_id') or request.get('form_id')
listbox = getattr(context, form_id).get_field(field_id) relation_field = getattr(context, form_id).get_field(field_id)
dialog_id = listbox.get_value('relation_form_id') or 'Base_viewRelatedObjectList' dialog_id = relation_field.get_value('relation_form_id') or 'Base_viewRelatedObjectList'
result = listbox.get_value(parameter)
# 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 result in [ [], (), None, '']:
if parameter == 'proxy_listbox_ids': if parameter == 'proxy_listbox_ids':
...@@ -21,17 +36,15 @@ if parameter is not None: ...@@ -21,17 +36,15 @@ if parameter is not None:
if parameter != 'parameter_list': if parameter != 'parameter_list':
result = getattr(context, dialog_id, None).get_field( 'listbox' ).get_orig_value(parameter) 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': if parameter == 'portal_type':
portal_type = listbox.get_value('portal_type') portal_type = relation_field.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)
if proxied_listbox is None: if proxied_listbox is None:
return portal_type return portal_type
proxied_listbox_portal_type = proxied_listbox.get_value('portal_types') proxied_listbox_portal_type = proxied_listbox.get_value('portal_types')
portal_type_first_item_list = [x[0] for x in portal_type] 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 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