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