Commit 2f7f49a3 authored by Jérome Perrin's avatar Jérome Perrin

support reports for "no project" or "no function" defined

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37029 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c188cb85
......@@ -55,6 +55,7 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from Products.ZSQLCatalog.SQLCatalog import Query\n
from Products.PythonScripts.standard import Object\n
from ZTUtils import LazyFilter\n
\n
......@@ -90,9 +91,15 @@ if group_analytic:\n
if portal_type and portal_type != portal.getPortalAccountingTransactionTypeList():\n
inventory_params[\'parent_portal_type\'] = portal_type\n
if function:\n
inventory_params[\'function\'] = function\n
if function == \'None\':\n
inventory_params[\'function_uid\'] = Query(function_uid=None)\n
else:\n
inventory_params[\'function\'] = function\n
if project:\n
inventory_params[\'project\'] = project\n
if project == \'None\':\n
inventory_params[\'project_uid\'] = Query(project_uid=None)\n
else:\n
inventory_params[\'project\'] = project\n
if mirror_section_category:\n
inventory_params[\'mirror_section_category\'] = mirror_section_category\n
\n
......@@ -818,6 +825,8 @@ return new_line_list\n
<string>group_analytic</string>
<string>mirror_section_category</string>
<string>kw</string>
<string>Products.ZSQLCatalog.SQLCatalog</string>
<string>Query</string>
<string>Products.PythonScripts.standard</string>
<string>Object</string>
<string>ZTUtils</string>
......@@ -844,6 +853,7 @@ return new_line_list\n
<string>inventory_params</string>
<string>_write_</string>
<string>tuple</string>
<string>None</string>
<string>MARKER</string>
<string>line_per_account</string>
<string>account_used</string>
......@@ -859,7 +869,6 @@ return new_line_list\n
<string>total_final_balance_if_credit</string>
<string>False</string>
<string>getKey</string>
<string>None</string>
<string>analytic_title_dict</string>
<string>getAnalyticTitleFromUid</string>
<string>_apply_</string>
......
......@@ -112,12 +112,21 @@ params = dict(at_date=at_date,\n
if from_date:\n
params[\'from_date\'] = from_date\n
if payment:\n
params[\'payment_uid\'] = traverse(payment).getUid()\n
if payment == \'None\':\n
params[\'payment_uid\'] = payment\n
else:\n
params[\'payment_uid\'] = traverse(payment).getUid()\n
if project:\n
params[\'project_uid\'] = traverse(project).getUid()\n
if project == \'None\':\n
params[\'project_uid\'] = project\n
else:\n
params[\'project_uid\'] = traverse(project).getUid()\n
if function:\n
params[\'function_uid\'] = traverse(function).getUid()\n
params[\'function\'] = function\n
if function == \'None\':\n
params[\'function_uid\'] = function\n
else:\n
params[\'function_uid\'] = traverse(function).getUid()\n
params[\'function\'] = function\n
if mirror_section:\n
params[\'mirror_section_uid\'] = traverse(mirror_section).getUid()\n
if parent_portal_type:\n
......
......@@ -55,7 +55,7 @@
<key> <string>_body</string> </key>
<value> <string>"""Returns the list of columns to use in accounting reports (GL, account statement, journal)\n
"""\n
\n
from Products.ZSQLCatalog.SQLCatalog import Query\n
portal = context.getPortalObject()\n
request = portal.REQUEST\n
\n
......@@ -72,13 +72,19 @@ if project_item_list:\n
analytic_column_list += ((\'project\', \'Project\'),)\n
for v, k in project_item_list:\n
if k:\n
project_title_dict[portal.portal_categories.restrictedTraverse(k).getUid()] = v\n
if k == \'None\' or isinstance(k, Query):\n
project_title_dict[None] = \'\'\n
else:\n
project_title_dict[portal.portal_categories.restrictedTraverse(k).getUid()] = v\n
function_item_list = context.AccountingTransactionLine_getFunctionItemList()\n
if function_item_list:\n
analytic_column_list += ((\'function\', context.AccountingTransactionLine_getFunctionBaseCategoryTitle()),)\n
for v, k in function_item_list:\n
if k:\n
function_title_dict[portal.portal_categories.restrictedTraverse(k).getUid()] = v\n
if k == \'None\' or isinstance(k, Query):\n
function_title_dict[None] = \'\'\n
else:\n
function_title_dict[portal.portal_categories.restrictedTraverse(k).getUid()] = v\n
for base_category in \\\n
portal.portal_preferences.getPreferredAccountingTransactionLineAnalyticBaseCategoryList() or []:\n
title = portal.portal_categories.restrictedTraverse(base_category).getTitle()\n
......@@ -121,6 +127,8 @@ return analytic_column_list\n
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>Products.ZSQLCatalog.SQLCatalog</string>
<string>Query</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
......@@ -135,6 +143,8 @@ return analytic_column_list\n
<string>_getiter_</string>
<string>v</string>
<string>k</string>
<string>isinstance</string>
<string>None</string>
<string>function_item_list</string>
<string>base_category</string>
<string>title</string>
......
......@@ -57,6 +57,7 @@
"""Get the report sections for general ledger\n
"""\n
from Products.ZSQLCatalog.SQLCatalog import Query\n
from Products.ERP5Form.Report import ReportSection\n
portal = context.portal_url.getPortalObject()\n
request = portal.REQUEST\n
......@@ -101,10 +102,16 @@ params = dict(precision=precision,\n
hide_grouping=request.get(\'omit_grouping_reference\', False))\n
project = request.get(\'project\')\n
if project:\n
params[\'project_uid\'] = portal.portal_categories.restrictedTraverse(project).getUid()\n
if project == \'None\':\n
params[\'project_uid\'] = Query(project_uid=None)\n
else:\n
params[\'project_uid\'] = portal.portal_categories.restrictedTraverse(project).getUid()\n
function = request.get(\'function\')\n
if function:\n
params[\'function_uid\'] = portal.portal_categories.restrictedTraverse(function).getUid()\n
if function == \'None\':\n
params[\'function_uid\'] = Query(function_uid=None)\n
else:\n
params[\'function_uid\'] = portal.portal_categories.restrictedTraverse(function).getUid()\n
\n
default_selection_params = params.copy()\n
\n
......@@ -376,7 +383,7 @@ for inventory in portal.portal_simulation.getInventoryList(\n
at_date=at_date,\n
group_by_node=1,\n
group_by_section=0,\n
group_by_paymnent=1,\n
group_by_payment=1,\n
group_by_resource=0,\n
**params):\n
key = (inventory.node_relative_url, None, inventory.payment_uid)\n
......@@ -405,7 +412,7 @@ for inventory in portal.portal_simulation.getInventoryList(\n
at_date=from_date,\n
group_by_node=1,\n
group_by_section=0,\n
group_by_paymnent=1,\n
group_by_payment=1,\n
group_by_resource=0,\n
**params):\n
key = (inventory.node_relative_url, None, inventory.payment_uid)\n
......@@ -481,6 +488,8 @@ return report_section_list\n
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>Products.ZSQLCatalog.SQLCatalog</string>
<string>Query</string>
<string>Products.ERP5Form.Report</string>
<string>ReportSection</string>
<string>_getattr_</string>
......
......@@ -58,6 +58,7 @@
This script is indented to be used on custom listfields for accounting lines, and on reports.\n
If this script returns an empty list, it means that reports by project are disabled.\n
"""\n
from Products.ERP5Type.Message import translateString\n
portal = context.getPortalObject()\n
request = portal.REQUEST\n
\n
......@@ -82,7 +83,7 @@ if context.getPortalType() == \'Accounting Transaction Module\':\n
project_list.sort(key=lambda x:x[0])\n
if not project_list:\n
return [] # returning an empty list, not to add project column on reports\n
return [(\'\', \'\')] + project_list\n
return [(\'\', \'\'), (translateString(\'No Project\'), \'None\')] + project_list\n
\n
# case 2: script is used on custom listfields.\n
# for now the script has to be customized in such case.\n
......@@ -124,6 +125,8 @@ return [(\'\', \'\')]\n
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>Products.ERP5Type.Message</string>
<string>translateString</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
......
......@@ -55,6 +55,7 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from Products.ZSQLCatalog.SQLCatalog import Query\n
from Products.ERP5Type.Message import translateString\n
from Products.ERP5Type.Log import log\n
portal = context.getPortalObject()\n
......@@ -74,12 +75,24 @@ if kw.get(\'node_uid\'):\n
params[\'node_uid\'] = kw[\'node_uid\']\n
if kw.get(\'mirror_section_uid\'):\n
params[\'mirror_section_uid\'] = kw[\'mirror_section_uid\']\n
if kw.get(\'payment_uid\'):\n
params[\'payment_uid\'] = kw[\'payment_uid\']\n
if kw.get(\'project_uid\'):\n
params[\'project_uid\'] = kw[\'project_uid\']\n
if kw.get(\'function_uid\'):\n
params[\'function_uid\'] = kw[\'function_uid\']\n
payment_uid = kw.get(\'payment_uid\')\n
if payment_uid:\n
if payment_uid == \'None\':\n
params[\'payment_uid\'] = Query(payment_uid=None)\n
else:\n
params[\'payment_uid\'] = payment_uid\n
project_uid = kw.get(\'project_uid\')\n
if project_uid:\n
if project_uid == \'None\':\n
params[\'project_uid\'] = Query(project_uid=None)\n
else:\n
params[\'project_uid\'] = project_uid\n
function_uid = kw.get(\'function_uid\')\n
if function_uid:\n
if function_uid == \'None\':\n
params[\'function_uid\'] = Query(function_uid=None)\n
else:\n
params[\'function_uid\'] = function_uid\n
if node_category_strict_membership:\n
params[\'node_category_strict_membership\'] = node_category_strict_membership\n
if node_category:\n
......@@ -208,7 +221,6 @@ if from_date or is_pl_account:\n
if context.portal_selections.getSelectionParamsFor(selection_name).get(\'hide_grouping\'):\n
params[\'where_expression\'] = \'catalog.grouping_reference is NULL\'\n
\n
\n
# We try not to convert to a list, hence the copy & paste\n
return portal.portal_simulation.getMovementHistoryList(\n
from_date=from_date,\n
......@@ -267,6 +279,8 @@ return portal.portal_simulation.getMovementHistoryList(\n
<string>selection_name</string>
<string>src__</string>
<string>kw</string>
<string>Products.ZSQLCatalog.SQLCatalog</string>
<string>Query</string>
<string>Products.ERP5Type.Message</string>
<string>translateString</string>
<string>Products.ERP5Type.Log</string>
......@@ -279,6 +293,9 @@ return portal.portal_simulation.getMovementHistoryList(\n
<string>None</string>
<string>_getitem_</string>
<string>_write_</string>
<string>payment_uid</string>
<string>project_uid</string>
<string>function_uid</string>
<string>new_result</string>
<string>net_balance</string>
<string>False</string>
......
......@@ -53,7 +53,8 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
<value> <string>from Products.ZSQLCatalog.SQLCatalog import Query\n
portal = context.getPortalObject()\n
params = portal.ERP5Accounting_getParams(selection_name=selection_name)\n
getInventoryAssetPrice = portal.portal_simulation.getInventoryAssetPrice\n
getSelectionDomainDictFor = context.portal_selections.getSelectionDomainDictFor\n
......@@ -64,14 +65,25 @@ if kw.get(\'node_uid\'):\n
if kw.get(\'mirror_section_uid\'):\n
params[\'mirror_section_uid\'] = kw[\'mirror_section_uid\']\n
\n
if kw.get(\'function_uid\'):\n
params[\'function_uid\'] = kw[\'function_uid\']\n
if kw.get(\'project_uid\'):\n
params[\'project_uid\'] = kw[\'project_uid\']\n
payment_uid = kw.get(\'payment_uid\')\n
if payment_uid:\n
if payment_uid == \'None\':\n
params[\'payment_uid\'] = Query(payment_uid=None)\n
else:\n
params[\'payment_uid\'] = payment_uid\n
project_uid = kw.get(\'project_uid\')\n
if project_uid:\n
if project_uid == \'None\':\n
params[\'project_uid\'] = Query(project_uid=None)\n
else:\n
params[\'project_uid\'] = project_uid\n
function_uid = kw.get(\'function_uid\')\n
if function_uid:\n
if function_uid == \'None\':\n
params[\'function_uid\'] = Query(function_uid=None)\n
else:\n
params[\'function_uid\'] = function_uid\n
\n
# FIXME: bank account uses quantity, not total_price\n
if kw.get(\'payment_uid\'):\n
params[\'payment_uid\'] = kw[\'payment_uid\']\n
if kw.get(\'node_category_strict_membership\'):\n
params[\'node_category_strict_membership\'] = \\\n
kw[\'node_category_strict_membership\']\n
......@@ -179,6 +191,8 @@ return getInventoryAssetPrice(\n
<string>omit_output</string>
<string>selection_name</string>
<string>kw</string>
<string>Products.ZSQLCatalog.SQLCatalog</string>
<string>Query</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
......@@ -187,9 +201,12 @@ return getInventoryAssetPrice(\n
<string>getSelectionDomainDictFor</string>
<string>_getitem_</string>
<string>_write_</string>
<string>payment_uid</string>
<string>None</string>
<string>project_uid</string>
<string>function_uid</string>
<string>node</string>
<string>period_start_date</string>
<string>None</string>
<string>at_date</string>
<string>_apply_</string>
<string>period_openning_balance</string>
......
1302
\ No newline at end of file
1309
\ 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