Commit 0d8242de authored by Jérome Perrin's avatar Jérome Perrin

accounting: fix grouping dialog loosing section category on next page

In xhtml_style, just after clicking next or previous page in the listbox
buttons, the values selected in 'Section Category' and 'Section Category
Strict' were not used, because they were used from request and not from
as normal script parameters.

This fixes only the xhtml_style version, ERP5JS has another problem that
dialog fields values are reset when going to next page, so it would also
need this problem to be fixed.
parent 9405ec7d
Pipeline #22674 failed with stage
......@@ -4,7 +4,7 @@ request = container.REQUEST
portal = context.getPortalObject()
# we use a different selection for dialog params, because we never want this
# selection to be reseteted
# selection to be reset
dialog_selection_params = portal.portal_selections.getSelectionParamsFor(
'grouping_reference_fast_input_selection')
......@@ -26,12 +26,20 @@ for column in portal.portal_selections.getSelectionSortOrder(
continue
sort_on.append((column_id, column[1]))
section_category = request.get(
'section_category',
portal.portal_preferences.getPreferredAccountingTransactionSectionCategory())
section_category_strict = request.get(
'section_category_strict',
portal.portal_preferences.getPreferredAccountingSectionCategoryStrict())
# XXX ERP5JS does call list method with selection parameters, so we have to read in request.
section_category = section_category \
or request.get('section_category') \
or dialog_selection_params.get('section_category') \
or portal.portal_preferences.getPreferredAccountingTransactionSectionCategory()
for candidate in (
section_category_strict,
request.get('section_category_strict'),
dialog_selection_params.get('section_category_strict'),
portal.portal_preferences.getPreferredAccountingSectionCategoryStrict(),
):
if candidate is not None:
section_category_strict = candidate
break
section_uid = portal.Base_getSectionUidListForSectionCategory(
section_category, section_category_strict)
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>selection=None, grouping=\'grouping\', node=\'\', mirror_section=\'\', ledger=\'\', title=None, delivery_reference=None, debit_price=None, credit_price=None, date=None, **kw</string> </value>
<value> <string>selection=None, grouping=\'grouping\', node=\'\', mirror_section=\'\', ledger=\'\', title=None, delivery_reference=None, debit_price=None, credit_price=None, date=None, section_category=\'\', section_category_strict=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
<?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>test_group_multi_pages_section_selection.html</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>Grouping with multiple pages and section selection</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="4">
Grouping with multiple pages and section selection
</td></tr>
</thead><tbody tal:define="init_method string:AccountingTransactionModule_createAccountingTransactionList?add_draft_transactions:int=0&month_count:int=6&add_related_payments:int=1&both_sections:int=1">
<!-- Setup {{{ -->
<tal:block metal:use-macro="here/ERP5Site_viewAccountingZuiteCommonTemplate/macros/init"/>
<tr>
<td>selectAndWait</td>
<td>select_module</td>
<td>Organisations</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Folder_show:method</td>
<td></td>
</tr>
<tr>
<td>type</td>
<!-- title -->
<td>//tr[@class='listbox-search-line']/th[2]/input</td>
<td>Client 1</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//input[@class="listbox-select-action"]</td>
<td></td>
</tr>
<!-- }}} -->
<!-- {{{ Select Client 1 Organisation and use grouping fast input -->
<tr>
<td>clickAndWait</td>
<td>link=Client 1</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//img[@alt='Grouping Reference Fast Input']</td>
<td></td>
</tr>
<!-- The mode should be 'grouping' by default -->
<tr>
<td>verifyValue</td>
<td>//input[@name='field_your_grouping' and @value='grouping']</td>
<td>on</td>
</tr>
<tr>
<td>verifyText</td>
<td>//label[contains(text(),"Total Selected Amount")]/../div[1]/</td>
<td>0.00</td>
</tr>
<tr>
<td>verifySelectedLabel</td>
<td>field_your_node</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>field_your_node</td>
<td>label=41 - Receivable</td>
</tr>
<tr>
<td>verifySelectedLabel</td>
<td>field_your_section_category</td>
<td>Demo Group</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@id="dialog_update_button"]</td>
<td></td>
</tr>
<tr>
<td>assertPortalStatusMessage</td>
<td>Updated</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>24 records</td>
</tr>
<tr>
<td>select</td>
<td>field_your_section_category</td>
<td>Demo Group</td>
</tr>
<tr>
<td>click</td>
<td>field_your_section_category_strict</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@id="dialog_update_button"]</td>
<td></td>
</tr>
<tr>
<td>assertPortalStatusMessage</td>
<td>Updated</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>12 records</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@class='listbox_next_page']</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>//span[@class='listbox-current-page-total-number']</td>
<td>12 records</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@class='listbox_previous_page']</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>//span[@class='listbox-current-page-total-number']</td>
<td>12 records</td>
</tr>
<tr>
<td>assertChecked</td>
<td>field_your_section_category_strict</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>field_your_section_category_strict</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@id="dialog_update_button"]</td>
<td></td>
</tr>
<tr>
<td>assertPortalStatusMessage</td>
<td>Updated</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>24 records</td>
</tr>
<tr>
<td>select</td>
<td>field_your_section_category</td>
<td>Demo Group/Subsidiairy #1</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@id="dialog_update_button"]</td>
<td></td>
</tr>
<tr>
<td>assertPortalStatusMessage</td>
<td>Updated</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>12 records</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@class='listbox_next_page']</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>//span[@class='listbox-current-page-total-number']</td>
<td>12 records</td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -2,7 +2,6 @@ from DateTime import DateTime
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
# params
section_title = 'My Organisation'
portal = context.getPortalObject()
accounting_module = portal.accounting_module
year = 2005
......@@ -14,9 +13,9 @@ business_process = portal.portal_catalog.getResultValue(
portal_type='Business Process').getRelativeUrl()
# if the previous test didn't change input data, no need to recreate content
current_script_data_id = '%s_month_count_%s_draft_%s_state_%s_payment_%s_leger_%s' % (
current_script_data_id = '%s_month_count_%s_draft_%s_state_%s_payment_%s_leger_%s_both_sections_%s' % (
month_count, add_draft_transactions, transaction_state,
add_related_payments, set_ledger, script.getId())
add_related_payments, set_ledger, both_sections, script.getId())
if accounting_module.getProperty('current_content_script',
'') == current_script_data_id:
......@@ -60,7 +59,10 @@ def getOrganisationByTitle(title):
assert len(document_list) == 1, \
'%d organisation with title "%s"' % (len(document_list), title)
return document_list[0]
section = getOrganisationByTitle(section_title)
section_list = [getOrganisationByTitle('My Organisation')]
if both_sections:
section_list.append(getOrganisationByTitle('My Master Organisation'))
euro_resource = 'currency_module/euro'
......@@ -75,6 +77,7 @@ else:
title='Dummy Product for testing')
for _ in range(random.randint(5, 10)):
for section in section_list:
pl = portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List',
title='Dummy Packing List for testing',
......@@ -94,7 +97,8 @@ for _ in range(random.randint(5, 10)):
#assert pl.getSimulationState() == 'stopped'
#pl.recursiveReindexObject()
for month in range(1, month_count + 1):
for section in section_list:
for month in range(1, month_count + 1):
default_date = DateTime(year, month, 1)
tr = accounting_module.newContent(
title='Accounts opening',
......@@ -244,7 +248,7 @@ for month in range(1, month_count + 1):
# other cases not supported for now
assert transaction_state == 'draft'
if add_draft_transactions:
if add_draft_transactions:
# finally, add random accounting transcactions in draft state, which have no
# impact on the test
for client_title, amount in (('Client 1', 2000), ('Client 2', 3000)):
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>month_count=1, add_draft_transactions=1, transaction_state=\'validated\', add_related_payments=0, keep_grouping_reference=0, set_ledger=0</string> </value>
<value> <string>month_count=1, add_draft_transactions=1, transaction_state=\'validated\', add_related_payments=0, keep_grouping_reference=0, set_ledger=0, both_sections=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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