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

accounting: fix "Total Selected Amount" not being updated after searching in...

accounting: fix "Total Selected Amount" not being updated after searching in grouping reference fast input
parent c3eca705
"""Selected amount in grouping fastinput is set in request by the update scripts,
but this update script will not be called when searching the listbox.
In that case, we can still calculcate.
"""
portal = context.getPortalObject()
selection_name = \
context.AccountingTransactionModule_viewGroupingFastInputDialog.listbox.get_value('selection_name')
getobject = portal.portal_catalog.getobject
selected_uid_list = portal.portal_selections.getSelectionCheckedUidsFor(selection_name)
total_selected_amount = 0
# calculate total selected amount
for uid in selected_uid_list or []:
line = getobject(uid)
if line.AccountingTransaction_isSourceView():
total_selected_amount += (line.getSourceInventoriatedTotalAssetPrice() or 0)
else:
total_selected_amount += (line.getDestinationInventoriatedTotalAssetPrice() or 0)
return total_selected_amount
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<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_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<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>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionModule_getGroupingReferenceFastInputTotalSelectedAmount</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -10,9 +10,9 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
<string>default</string>
<string>editable</string>
<string>title</string>
</list>
</value>
</item>
......@@ -60,6 +60,10 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -72,6 +76,10 @@
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -117,7 +125,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>request/total_selected_amount | python: 0</string> </value>
<value> <string>request/total_selected_amount | context/AccountingTransactionModule_getGroupingReferenceFastInputTotalSelectedAmount</string> </value>
</item>
</dictionary>
</pickle>
......
<?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_selected_amount_updated_when_searching.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>Selected amount updated when searching</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="4">
Selected amount updated when searching
</td></tr>
</thead><tbody tal:define="init_method string:AccountingZuite_createAccountingTransactionList?add_draft_transactions:int=0&month_count:int=6&add_related_payments:int=1">
<!-- Setup {{{ -->
<tal:block metal:use-macro="here/AccountingZuite_CommonTemplate/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>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>
<!-- select one line -->
<tr>
<td>click</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[1]/input</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@id="dialog_update_button"]</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>//span[@class='listbox-current-item-number']</td>
<td>- 1 items selected</td>
</tr>
<tr>
<td>verifyText</td>
<td>//label[contains(text(),"Total Selected Amount")]/../div[1]/</td>
<td>2 200.00</td>
</tr>
<!-- search -->
<tr>
<td>type</td>
<td>//tr[@class='listbox-search-line']/th[5]/input</td>
<td></td>
</tr>
<tr>
<td>type</td>
<!-- date -->
<td>//tr[@class='listbox-search-line']/th[6]/input</td>
<td>2005/01/02</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//input[@class="listbox-select-action"]</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>2 records</td>
</tr>
<!-- The selected amount is still displayed properly directly after search -->
<tr>
<td>verifyText</td>
<td>//span[@class='listbox-current-item-number']</td>
<td>- 1 items selected</td>
</tr>
<tr>
<td>verifyText</td>
<td>//label[contains(text(),"Total Selected Amount")]/../div[1]/</td>
<td>2 200.00</td>
</tr>
<!-- Click "update" button, the selected amount is still displayed properly -->
<tr>
<td>clickAndWait</td>
<td>//button[@id="dialog_update_button"]</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>//span[@class='listbox-current-item-number']</td>
<td>- 1 items selected</td>
</tr>
<tr>
<td>verifyText</td>
<td>//label[contains(text(),"Total Selected Amount")]/../div[1]/</td>
<td>2 200.00</td>
</tr>
</tbody></table>
</body>
</html> <!-- vim: syntax=html foldmethod=marker
-->
\ No newline at end of file
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