Commit e3067a2e authored by Vincent Pelletier's avatar Vincent Pelletier

PaymentTransactionGroup_view/listbox: Add a count method.

Use a single query for count and stat methods, caching the result in request
(for lack of a better idea).
Also, stop defining editable columns, as listbox auto-detects such fields
anyway.
parent 4ce8f370
count, _ = context.PaymentTransactionGroup_getPaymentTransactionLineCountAndStat()
return ((count, ), )
<?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>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransactionGroup_countPaymentTransactionLine</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
cache = portal.REQUEST.other
cache_key = context.getId() + '_' + script.id
try:
return cache[cache_key]
except KeyError:
row, = portal.portal_simulation.getInventoryList(
select_dict={'count': 'COUNT(*)'},
ignore_group_by=1,
section_uid=context.getSourceSectionUid(),
strict_aggregate_uid=context.getUid(),
node_uid=[x.uid for x in portal.portal_catalog(
portal_type='Account',
strict_account_type_uid=portal.portal_categories.account_type.asset.cash.bank.getUid(),
)],
)
cache[cache_key] = result = (row.count, row.total_quantity)
return result
<?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>PaymentTransactionGroup_getPaymentTransactionLineCountAndStat</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.PythonScripts.standard import Object
portal = context.getPortalObject()
kw.update({
'section_uid': context.getSourceSectionUid(),
'strict_aggregate_uid': context.getUid(),
'node_uid': [x.uid for x in portal.portal_catalog(
portal_type='Account',
strict_account_type_uid=portal.portal_categories.account_type.asset.cash.bank.getUid(),
)],
})
return Object(total_quantity=portal.portal_simulation.getInventory(**kw)),
_, total_quantity = context.PaymentTransactionGroup_getPaymentTransactionLineCountAndStat()
return Object(total_quantity=total_quantity),
......@@ -11,7 +11,7 @@
<value>
<list>
<string>columns</string>
<string>editable_columns</string>
<string>count_method</string>
<string>list_method</string>
<string>selection_name</string>
<string>stat_method</string>
......@@ -61,10 +61,6 @@
<key> <string>columns</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable_columns</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -132,22 +128,17 @@
<string>getTranslatedSimulationStateTitle</string>
<string>State</string>
</tuple>
<tuple>
<string>specialise_title</string>
<string>Mandate</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>editable_columns</string> </key>
<key> <string>count_method</string> </key>
<value>
<list>
<tuple>
<string>total_price</string>
<string>total_price</string>
</tuple>
<tuple>
<string>date</string>
<string>date</string>
</tuple>
</list>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
......@@ -161,7 +152,7 @@
<item>
<key> <string>list_method</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
......@@ -171,7 +162,7 @@
<item>
<key> <string>stat_method</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
......@@ -196,12 +187,25 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>PaymentTransactionGroup_getPaymentTransactionLineList</string> </value>
<value> <string>PaymentTransactionGroup_countPaymentTransactionLine</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Method" module="Products.Formulator.MethodField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>PaymentTransactionGroup_getPaymentTransactionLineList</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="Method" module="Products.Formulator.MethodField"/>
</pickle>
......
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