Commit 45c469ee authored by Jérome Perrin's avatar Jérome Perrin

add new script ERP5Accounting_getParams that get parameters from...

add new script ERP5Accounting_getParams that get parameters from selection/preference (and uses a request cache
AccountModule_getAccountingTransactionCount apply the selection filter for the stat method



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9727 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 610e7ac1
...@@ -68,53 +68,34 @@ ...@@ -68,53 +68,34 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>LOG=lambda message: context.log("AccountModule_getAccountingTransactionCount", message)\n <value> <string>kwd = context.ERP5Accounting_getParams(selection)\n
\n \n
params = selection.getParams()\n # XXX missing :(\n
kwd = {} \n # this may fail if we have movements on something else than accounts\n
#kwd[\'where_expression\'] = \'node.parent_uid = %s\' context.account_module.getUid()\n
\n \n
# read settings from user preference\n if kw.get(\'stat\'):\n
preference = context.getPortalObject().portal_preferences\n selection_params = selection.getParams()\n
from_date = params.get(\'from_date\', preference.getPreferredAccountingTransactionFromDate())\n if selection.getDomain():\n
if from_date :\n
kwd[\'from_date\'] = from_date\n
at_date = params.get(\'at_date\', preference.getPreferredAccountingTransactionAtDate())\n
if at_date :\n
kwd[\'at_date\'] = at_date\n
section_category = params.get(\'section_category\', preference.getPreferredAccountingTransactionSectionCategory())\n
if section_category :\n
kwd[\'section_category\'] = section_category\n
\n
simulation_state = params.get(\'simulation_state\', preference.getPreferredAccountingTransactionSimulationStateList())\n
if simulation_state :\n
kwd[\'simulation_state\'] = simulation_state\n
\n
resource = params.get(\'accounting_transaction_line_currency\')\n
if resource:\n
currency = context.portal_categories.resolveCategory(resource)\n
kwd[\'resource_uid\'] = [currency.getUid()]\n
\n
query = {} #context.portal_catalog.buildSQLQuery(query_table=\'node\', **kwd)\n
if query.get(\'where_expression\'):\n
kwd[\'where_expression\'] = query[\'where_expression\']\n
if query.get(\'from_table_list\'):\n
kwd[\'from_table_list\'] = query[\'from_table_list\']\n
\n
if kw.get(\'stat\') :\n
if selection.getDomain() :\n
kwd[\'selection_domain\'] = selection.getDomain()\n kwd[\'selection_domain\'] = selection.getDomain()\n
if selection.getReport() :\n if selection.getReport():\n
kwd[\'selection_report\'] = selection.getReport()\n kwd[\'selection_report\'] = selection.getReport()\n
if params.get(\'closed_summary\'):\n if selection_params.get(\'closed_summary\'):\n
kwd[\'closed_summary\'] = params[\'closed_summary\']\n kwd[\'closed_summary\'] = selection_params[\'closed_summary\']\n
if selection.isInvertMode() :\n if selection.isInvertMode():\n
kwd[\'selection_uids\'] = selection.getInvertModeUidList()\n kwd[\'selection_uids\'] = selection.getInvertModeUidList()\n
return context.portal_simulation.getInventoryStat(omit_simulation=1,\n # is list filtered ?\n
**kwd)[0][\'stock_uid\']\n if \'title\' in selection_params or \\\n
\'preferred_gap_id\' in selection_params or\\\n
\'transalated_validation_state_title\' in selection_params:\n
# if yes, apply the same filter here\n
kwd[\'stock.node_uid\'] = [x.uid for x in\n
context.portal_catalog(**selection.getParams())]\n
return context.portal_simulation.getInventoryStat( **kwd )[0][\'stock_uid\']\n
\n \n
return context.portal_simulation.getInventoryStat(node_uid=context.getUid(),\n kwd[\'stock.node_uid\'] = brain.uid\n
omit_simulation=1,\n return context.portal_simulation.getInventoryStat( **kwd )[0][\'stock_uid\']\n
**kwd)[0][\'stock_uid\']\n # vim: syntax=python\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -166,22 +147,17 @@ return context.portal_simulation.getInventoryStat(node_uid=context.getUid(),\n ...@@ -166,22 +147,17 @@ return context.portal_simulation.getInventoryStat(node_uid=context.getUid(),\n
<string>selection</string> <string>selection</string>
<string>brain</string> <string>brain</string>
<string>kw</string> <string>kw</string>
<string>LOG</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>params</string>
<string>kwd</string>
<string>context</string> <string>context</string>
<string>preference</string> <string>kwd</string>
<string>from_date</string> <string>selection_params</string>
<string>_write_</string> <string>_write_</string>
<string>at_date</string>
<string>section_category</string>
<string>simulation_state</string>
<string>resource</string>
<string>currency</string>
<string>query</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>_apply_</string> <string>_apply_</string>
<string>x</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>_body</string> </key>
<value> <string>"""Returns all parameters from preferences or selection.\n
\n
This script gives priority to selection, and if not found in selection, it\n
tries to get the parameters from preference tool.\n
All parameters are stored/retrieved in a REQUEST cache, unless ignore_cache\n
argument is True.\n
\n
caveats:\n
* wants_from_date parameter is not taken into account in the cache.\n
"""\n
\n
# do we have a cache already?\n
# XXX take selection into account ?\n
if not ignore_cache:\n
params_cache = context.REQUEST.other.get(\n
\'ERP5Accounting_getParams\', None)\n
if params_cache is not None:\n
return dict(params_cache)\n
\n
params = {}\n
selection_params = {}\n
if selection is not None:\n
selection_params = selection.getParams()\n
preference = context.getPortalObject().portal_preferences\n
\n
if wants_from_date:\n
from_date = selection_params.get(\'from_date\',\n
preference.getPreferredAccountingTransactionFromDate())\n
if from_date :\n
params[\'from_date\'] = from_date\n
\n
at_date = params.get(\'at_date\',\n
preference.getPreferredAccountingTransactionAtDate())\n
if at_date:\n
params[\'at_date\'] = at_date\n
\n
section_category = params.get(\'section_category\',\n
preference.getPreferredAccountingTransactionSectionCategory())\n
if section_category:\n
params[\'section_category\'] = section_category\n
\n
simulation_state = params.get(\'simulation_state\',\n
preference.getPreferredAccountingTransactionSimulationStateList())\n
if simulation_state:\n
params[\'simulation_state\'] = simulation_state\n
\n
if not ignore_cache:\n
context.REQUEST.other[\'ERP5Accounting_getParams\'] = params\n
return dict(params)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>selection=None, wants_from_date=0, ignore_cache=0</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>selection</string>
<string>wants_from_date</string>
<string>ignore_cache</string>
<string>_getattr_</string>
<string>context</string>
<string>None</string>
<string>params_cache</string>
<string>dict</string>
<string>params</string>
<string>selection_params</string>
<string>preference</string>
<string>from_date</string>
<string>_write_</string>
<string>at_date</string>
<string>section_category</string>
<string>simulation_state</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<int>0</int>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Accounting_getParams</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
24 25
\ No newline at end of file \ 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