Commit 22ca41cc authored by Jérome Perrin's avatar Jérome Perrin

bug fixes in order module report:

- DateTimeKey does not accept None, explitly use a DefaultKey for this
- if no organisations are member of the selected group, then default_destination_section_uid=[] will be used, which is skipped by catalog, use default_destination_section_uid=-1 not to match any
- if an order with no date was selected, then calling strftime failed

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26019 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 271fc632
...@@ -69,13 +69,15 @@ selection_columns = [(\'group_by\', "Group by")]\n ...@@ -69,13 +69,15 @@ selection_columns = [(\'group_by\', "Group by")]\n
if from_date is None:\n if from_date is None:\n
# get the minimum start date in catalog\n # get the minimum start date in catalog\n
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery\n from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery\n
kw = {"delivery.start_date" : None}\n kw = {"delivery.start_date" : None, "key":"DefaultKey"}\n
q = NegatedQuery(Query(**kw)) \n q = NegatedQuery(Query(**kw)) \n
select_expression = "MIN(delivery.start_date)"\n select_expression = "MIN(delivery.start_date)"\n
group_by = "delivery.start_date"\n group_by = "delivery.start_date"\n
from_date = DateTime(context.portal_catalog(select_expression=select_expression,\n from_date = DateTime(context.portal_catalog(select_expression=select_expression,\n
group_by_expression=group_by,query=q,\n group_by_expression=group_by,query=q,\n
limit=1)[0][2])\n limit=1)[0][2])\n
\n
\n
# get period list between given date\n # get period list between given date\n
interval_list_dict = getIntervalListBetweenDates(from_date=from_date, to_date=to_date,\n interval_list_dict = getIntervalListBetweenDates(from_date=from_date, to_date=to_date,\n
keys={\'year\':aggregation_level=="year",\n keys={\'year\':aggregation_level=="year",\n
...@@ -84,6 +86,7 @@ interval_list_dict = getIntervalListBetweenDates(from_date=from_date, to_date=to ...@@ -84,6 +86,7 @@ interval_list_dict = getIntervalListBetweenDates(from_date=from_date, to_date=to
\'day\':aggregation_level=="day"})\n \'day\':aggregation_level=="day"})\n
interval_list = interval_list_dict[aggregation_level]\n interval_list = interval_list_dict[aggregation_level]\n
\n \n
# FIXME: translate column names\n
# list columns of the listbox\n # list columns of the listbox\n
interval_column_list = []\n interval_column_list = []\n
if group_by == "client":\n if group_by == "client":\n
......
...@@ -79,10 +79,10 @@ if group not in (\'\', None):\n ...@@ -79,10 +79,10 @@ if group not in (\'\', None):\n
group_uid = category_tool.group.restrictedTraverse(group).getUid()\n group_uid = category_tool.group.restrictedTraverse(group).getUid()\n
organisation_uid_list = [x.uid for x in portal.portal_catalog(portal_type="Organisation", default_group_uid=group_uid)]\n organisation_uid_list = [x.uid for x in portal.portal_catalog(portal_type="Organisation", default_group_uid=group_uid)]\n
if report_type == "sale":\n if report_type == "sale":\n
catalog_params[\'default_source_section_uid\'] = organisation_uid_list\n catalog_params[\'default_source_section_uid\'] = organisation_uid_list or -1\n
elif report_type:\n elif report_type:\n
catalog_params[\'default_destination_section_uid\'] = organisation_uid_list\n catalog_params[\'default_destination_section_uid\'] = organisation_uid_list or -1\n
\n \n
# add category params if defined\n # add category params if defined\n
if incoterm not in (\'\', None):\n if incoterm not in (\'\', None):\n
incoterm_uid = category_tool.incoterm.restrictedTraverse(incoterm).getUid()\n incoterm_uid = category_tool.incoterm.restrictedTraverse(incoterm).getUid()\n
...@@ -117,6 +117,7 @@ elif to_date is not None:\n ...@@ -117,6 +117,7 @@ elif to_date is not None:\n
query = Query(range="ngt", **params)\n query = Query(range="ngt", **params)\n
\n \n
sort_on_list = [ (\'delivery.destination_section_uid\', \'ASC\'), (\'delivery.start_date\',\'ASC\')]\n sort_on_list = [ (\'delivery.destination_section_uid\', \'ASC\'), (\'delivery.start_date\',\'ASC\')]\n
\n
result_list = context.portal_catalog.searchResults(limit=None,query=query,\n result_list = context.portal_catalog.searchResults(limit=None,query=query,\n
portal_type=doc_portal_type,\n portal_type=doc_portal_type,\n
simulation_state=simulation_state,\n simulation_state=simulation_state,\n
...@@ -130,7 +131,9 @@ client_dict = {}\n ...@@ -130,7 +131,9 @@ client_dict = {}\n
product_dict = {}\n product_dict = {}\n
for result in result_list:\n for result in result_list:\n
result = result.getObject()\n result = result.getObject()\n
period = result.getStartDate().strftime(date_format)\n period = result.getStartDate()\n
if period is not None:\n
period = period.strftime(date_format)\n
if report_group_by in ("client", "both"):\n if report_group_by in ("client", "both"):\n
# client_title -> period -> amount\n # client_title -> period -> amount\n
if report_type == "sale":\n if report_type == "sale":\n
......
606 607
\ 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