Commit bcaba5fa authored by Nicolas Delaby's avatar Nicolas Delaby

Make results consistent regarding date range in same Form Report

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24505 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e2460a8c
......@@ -55,17 +55,21 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from Products.ERP5Type.DateUtils import atTheEndOfPeriod\n
request = container.REQUEST\n
from_date = request.get(\'from_date\', None)\n
to_date = request.get(\'at_date\', None)\n
aggregation_level = request.get(\'aggregation_level\', None)\n
if to_date is not None:\n
to_date = atTheEndOfPeriod(to_date, period=aggregation_level)\n
career_list = []\n
if from_date is None and to_date is None:\n
career_list = context.contentValues(filter={\'portal_type\':\'Career\'})\n
else:\n
for career in context.contentValues(filter={\'portal_type\':\'Career\'}):\n
if from_date is not None and to_date is not None:\n
if career.getStartDate() >= from_date and career.getStartDate() <= to_date \\\n
or career.getStopDate() <= to_date and career.getStopDate() >= from_date \\\n
if career.getStartDate() >= from_date and career.getStartDate() < to_date \\\n
or career.getStopDate() < to_date and career.getStopDate() >= from_date \\\n
or career.getStartDate() < from_date and career.getStopDate() > to_date:\n
career_list.append(career)\n
elif from_date is not None:\n
......@@ -73,8 +77,8 @@ else:\n
or career.getStopDate() >= from_date:\n
career_list.append(career)\n
elif to_date is not None:\n
if career.getStartDate() <= to_date \\\n
or career.getStopDate() <= to_date :\n
if career.getStartDate() < to_date \\\n
or career.getStopDate() < to_date :\n
career_list.append(career)\n
\n
def date_cmp(a, b):\n
......@@ -121,12 +125,15 @@ return career_list\n
<value>
<tuple>
<string>kw</string>
<string>Products.ERP5Type.DateUtils</string>
<string>atTheEndOfPeriod</string>
<string>_getattr_</string>
<string>container</string>
<string>request</string>
<string>None</string>
<string>from_date</string>
<string>to_date</string>
<string>aggregation_level</string>
<string>career_list</string>
<string>context</string>
<string>_getiter_</string>
......
......@@ -102,9 +102,10 @@ select_expression = \'DATE_FORMAT(creation_date, "%s") as date, portal_type\' %s
group_by = \'DATE_FORMAT(creation_date, "%s"), portal_type\' %sql_format\n
\n
# count number of object created by the user for each type of document\n
reference = request.get(\'person_reference_list\', context.getReference())\n
result_list = context.portal_catalog.countResults(select_expression=select_expression,\n
portal_type=portal_type_list,limit=None,\n
owner=context.getReference(),query=query,\n
owner=reference,query=query,\n
group_by_expression=group_by)\n
\n
# build result dict per portal_type then period\n
......@@ -229,6 +230,7 @@ return line_list\n
<string>_apply_</string>
<string>select_expression</string>
<string>group_by</string>
<string>reference</string>
<string>result_list</string>
<string>portal_type_count_dict</string>
<string>result</string>
......
......@@ -54,22 +54,25 @@
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ZSQLCatalog.SQLCatalog import Query\n
from Products.ERP5Type.DateUtils import atTheEndOfPeriod\n
request = container.REQUEST\n
portal = context.getPortalObject()\n
from_date = request.get(\'from_date\', None)\n
to_date = request.get(\'at_date\', None)\n
\n
aggregation_level = request.get(\'aggregation_level\', None)\n
if to_date is not None:\n
to_date = atTheEndOfPeriod(to_date, period=aggregation_level)\n
# build query based on dates\n
query=None\n
if from_date is not None and to_date is not None: \n
params = {"delivery.start_date":(from_date, to_date)}\n
query = Query(range="minngt", **params)\n
query = Query(range="minmax", **params)\n
elif from_date is not None:\n
params = {"delivery.start_date":from_date}\n
query = Query(range="min", **params)\n
elif to_date is not None:\n
params = {"delivery.start_date":to_date}\n
query = Query(range="ngt", **params)\n
query = Query(range="max", **params)\n
\n
event_type_list = portal.getPortalEventTypeList()\n
# get events where user is either source or destination\n
......@@ -123,6 +126,8 @@ return event_list\n
<string>kw</string>
<string>Products.ZSQLCatalog.SQLCatalog</string>
<string>Query</string>
<string>Products.ERP5Type.DateUtils</string>
<string>atTheEndOfPeriod</string>
<string>_getattr_</string>
<string>container</string>
<string>request</string>
......@@ -131,6 +136,7 @@ return event_list\n
<string>None</string>
<string>from_date</string>
<string>to_date</string>
<string>aggregation_level</string>
<string>query</string>
<string>params</string>
<string>_apply_</string>
......
......@@ -12,7 +12,9 @@
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
......@@ -90,6 +92,10 @@
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>To Date</string> </value>
</item>
</dictionary>
</value>
</item>
......
462
\ No newline at end of file
463
\ 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