From 7ba6cf9807ae348b1468a189e9e2a2b038bb0d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 22 Nov 2006 21:34:22 +0000 Subject: [PATCH] Allow to reuse the generated SQL for accounting module selection in other queries git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11451 20353a03-c40f-0410-a6d1-a30d3c3de9de --- ...ionModule_getAccountingTransactionList.xml | 22 ++++- ...onModule_zGetAccountingTransactionList.xml | 93 +++++++++++-------- bt5/erp5_accounting/bt/revision | 2 +- 3 files changed, 76 insertions(+), 41 deletions(-) diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getAccountingTransactionList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getAccountingTransactionList.xml index c0e1a8f291..ab80091201 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getAccountingTransactionList.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getAccountingTransactionList.xml @@ -91,11 +91,23 @@ if params.get(\'count\', 0):\n params[\'omit_input\'] = 0\n params[\'omit_output\'] = 0\n \n +# XXX this workaround is probably no longer needed\n if params.get(\'delivery_start_date\'):\n params[\'delivery.start_date\'] = params[\'delivery_start_date\']\n \n -#context.log(\'LOG (%s)\' % params, context.AccountingTransactionModule_zGetAccountingTransactionList(src__ =1, selection_params=params, **params))\n -return context.AccountingTransactionModule_zGetAccountingTransactionList(selection_params=params, **params)\n +# this method can be used to build another complex query, for example\n +# as a catalog.parent_uid filter with SimulationTool.getMovementList.\n +# In this example, you can use side independant inventory API with \n +# accounting module selection. see erp5_accounting_l10n_fr_m9 for an example.\n +src__ = context.REQUEST.other.get(\'src__\', 0)\n +no_limit = context.REQUEST.other.get(\'no_limit\', 0)\n +search_result_keys = context.REQUEST.other.get(\'search_result_keys\', None)\n +\n +return context.AccountingTransactionModule_zGetAccountingTransactionList( \n + selection_params=params,\n + src__=src__,\n + search_result_keys=search_result_keys,\n + no_limit=no_limit, **params)\n ]]></string> </value> @@ -144,8 +156,12 @@ return context.AccountingTransactionModule_zGetAccountingTransactionList(selecti <string>_write_</string> <string>_getattr_</string> <string>_getitem_</string> - <string>_apply_</string> <string>context</string> + <string>src__</string> + <string>no_limit</string> + <string>None</string> + <string>search_result_keys</string> + <string>_apply_</string> </tuple> </value> </item> diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml index 561a166750..96a84b2b74 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml @@ -139,6 +139,12 @@ </dictionary> </value> </item> + <item> + <key> <string>no_limit</string> </key> + <value> + <dictionary/> + </value> + </item> <item> <key> <string>node</string> </key> <value> @@ -183,6 +189,17 @@ </dictionary> </value> </item> + <item> + <key> <string>search_result_keys</string> </key> + <value> + <dictionary> + <item> + <key> <string>default</string> </key> + <value> <string encoding="base64">Jyc=</string> </value> + </item> + </dictionary> + </value> + </item> <item> <key> <string>section_category</string> </key> <value> @@ -281,30 +298,32 @@ <key> <string>_keys</string> </key> <value> <list> - <string>selection</string> - <string>selection_domain</string> - <string>selection_report</string> - <string>selection_params</string> - <string>selection_sort_on</string> - <string>select_expression</string> - <string>from_date</string> - <string>at_date</string> - <string>to_date</string> - <string>node</string> - <string>resource</string> - <string>entity</string> - <string>stat</string> - <string>omit_input</string> - <string>omit_output</string> - <string>amount</string> - <string>amount_range_min</string> - <string>amount_range_max</string> - <string>creation_date_range_min</string> - <string>creation_date_range_max</string> - <string>section_category</string> - <string>count</string> - <string>transaction_uid</string> - <string>specific_reference</string> +<string>selection</string> +<string>selection_domain</string> +<string>selection_report</string> +<string>selection_params</string> +<string>selection_sort_on</string> +<string>select_expression</string> +<string>from_date</string> +<string>at_date</string> +<string>to_date</string> +<string>node</string> +<string>resource</string> +<string>entity</string> +<string>stat</string> +<string>omit_input</string> +<string>omit_output</string> +<string>amount</string> +<string>amount_range_min</string> +<string>amount_range_max</string> +<string>creation_date_range_min</string> +<string>creation_date_range_max</string> +<string>section_category</string> +<string>count</string> +<string>transaction_uid</string> +<string>specific_reference</string> +<string>no_limit</string> +<string>search_result_keys</string> </list> </value> </item> @@ -344,7 +363,9 @@ creation_date_range_max=""\r\n section_category=""\r\n count=""\r\n transaction_uid=""\r\n -specific_reference</string> </value> +specific_reference\r\n +no_limit\r\n +search_result_keys=\'\'</string> </value> </item> <item> <key> <string>cache_time_</string> </key> @@ -386,9 +407,8 @@ specific_reference</string> </value> <dtml-let allowed_roles_and_users="portal_catalog.getAllowedRolesAndUsers(**selection_params)">\n <dtml-comment>do something to have a query without RolesAndUsers security for global stats</dtml-comment>\n -<dtml-let query="(stat) and portal_catalog.buildSQLQuery(**selection_params) or\n -portal_catalog.buildSQLQuery(allowedRolesAndUsers=allowed_roles_and_users, **selection_params)">\n -\n +<dtml-let query="(stat) and portal_catalog.buildSQLQuery(**selection_params) or portal_catalog.buildSQLQuery(allowedRolesAndUsers=allowed_roles_and_users, **selection_params)">\n +<dtml-let search_result_keys="search_result_keys or portal_catalog.getCatalogSearchResultKeys()">\n <dtml-let use_movement_table="from_date or to_date or at_date or resource or stat or amount or amount_range_min or amount_range_max">\n \n SELECT\n @@ -398,7 +418,7 @@ SELECT\n COUNT(DISTINCT catalog.uid) AS count\n <dtml-else>\n DISTINCT\n - <dtml-in "portal_catalog.getCatalogSearchResultKeys()">\n + <dtml-in "search_result_keys">\n <dtml-unless sequence-start>,</dtml-unless>\n <dtml-var sequence-item>\n </dtml-in>\n @@ -528,10 +548,10 @@ WHERE\n <dtml-if "query[\'limit_expression\']">\n LIMIT <dtml-var "query[\'limit_expression\']">\n <dtml-else>\n - LIMIT 1000\n + <dtml-unless no_limit>LIMIT 1000</dtml-unless>\n </dtml-if>\n </dtml-unless>\n -</dtml-let></dtml-let></dtml-let>\n +</dtml-let></dtml-let></dtml-let></dtml-let>\n <dtml-comment> vim: syntax=dtml\n </dtml-comment>\n @@ -574,9 +594,8 @@ WHERE\n <dtml-let allowed_roles_and_users="portal_catalog.getAllowedRolesAndUsers(**selection_params)">\n <dtml-comment>do something to have a query without RolesAndUsers security for global stats</dtml-comment>\n -<dtml-let query="(stat) and portal_catalog.buildSQLQuery(**selection_params) or\n -portal_catalog.buildSQLQuery(allowedRolesAndUsers=allowed_roles_and_users, **selection_params)">\n -\n +<dtml-let query="(stat) and portal_catalog.buildSQLQuery(**selection_params) or portal_catalog.buildSQLQuery(allowedRolesAndUsers=allowed_roles_and_users, **selection_params)">\n +<dtml-let search_result_keys="search_result_keys or portal_catalog.getCatalogSearchResultKeys()">\n <dtml-let use_movement_table="from_date or to_date or at_date or resource or stat or amount or amount_range_min or amount_range_max">\n \n SELECT\n @@ -586,7 +605,7 @@ SELECT\n COUNT(DISTINCT catalog.uid) AS count\n <dtml-else>\n DISTINCT\n - <dtml-in "portal_catalog.getCatalogSearchResultKeys()">\n + <dtml-in "search_result_keys">\n <dtml-unless sequence-start>,</dtml-unless>\n <dtml-var sequence-item>\n </dtml-in>\n @@ -716,10 +735,10 @@ WHERE\n <dtml-if "query[\'limit_expression\']">\n LIMIT <dtml-var "query[\'limit_expression\']">\n <dtml-else>\n - LIMIT 1000\n + <dtml-unless no_limit>LIMIT 1000</dtml-unless>\n </dtml-if>\n </dtml-unless>\n -</dtml-let></dtml-let></dtml-let>\n +</dtml-let></dtml-let></dtml-let></dtml-let>\n <dtml-comment> vim: syntax=dtml\n </dtml-comment>\n diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision index dd1ec209f3..fa59ff276d 100644 --- a/bt5/erp5_accounting/bt/revision +++ b/bt5/erp5_accounting/bt/revision @@ -1 +1 @@ -132 \ No newline at end of file +134 \ No newline at end of file -- 2.30.9