Commit 8a34a012 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_project: make task report searchable and sortable

date and state are not supported yet
parent 5109aabb
......@@ -126,7 +126,7 @@
<string>Task Title</string>
</tuple>
<tuple>
<string>getTranslatedPortalType</string>
<string>translated_portal_type</string>
<string>Type</string>
</tuple>
<tuple>
......@@ -198,8 +198,12 @@
<value>
<list>
<tuple>
<string>Task</string>
<string>Task</string>
<string>Task Line</string>
<string>Task Line</string>
</tuple>
<tuple>
<string>Task Report Line</string>
<string>Task Report Line</string>
</tuple>
</list>
</value>
......@@ -230,7 +234,36 @@
<item>
<key> <string>sort_columns</string> </key>
<value>
<list/>
<list>
<tuple>
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>parent_title</string>
<string>Task Title</string>
</tuple>
<tuple>
<string>translated_portal_type</string>
<string>Type</string>
</tuple>
<tuple>
<string>title</string>
<string>Task Line Title</string>
</tuple>
<tuple>
<string>source_title</string>
<string>Assignee</string>
</tuple>
<tuple>
<string>resource_title</string>
<string>Resource</string>
</tuple>
<tuple>
<string>destination_title</string>
<string>Location</string>
</tuple>
</list>
</value>
</item>
<item>
......
......@@ -2,12 +2,14 @@ source_project_uid_list = [x.uid for x in context.portal_catalog(
relative_url='%s/%%' % context.getRelativeUrl())] + [context.getUid()]
from Products.ZSQLCatalog.SQLCatalog import Query
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
sql_kw = {}
if kw.has_key('from_date') and kw['from_date'] is not None:
query_kw = {'delivery.start_date' : kw['from_date'],
'range' : 'min'}
sql_kw['delivery.start_date'] = Query(**query_kw)
if kw.has_key('at_date') and kw['at_date'] is not None:
query_kw = {'delivery.stop_date' : kw['at_date'],
'range' : 'ngt'}
......@@ -22,7 +24,6 @@ else:
task_simulation_state = context.getPortalDraftOrderStateList() + \
context.getPortalPlannedOrderStateList()
task_report_simulation_state = ""
task_list = [x.getObject() for x in \
context.portal_catalog(selection_report=selection_report,
portal_type='Task',
......@@ -35,17 +36,37 @@ task_list.extend([x.getObject() for x in \
source_project_uid = source_project_uid_list,
simulation_state = task_report_simulation_state,
**sql_kw)])
task_line_list = []
for task in task_list:
task_line_list.extend(task.objectValues(portal_type=('Task Line', 'Task Report Line')))
key_value = kw.pop('source_title', None)
if key_value:
kw['source_title_query'] = ComplexQuery(SimpleQuery(source_title=key_value),
SimpleQuery(parent_source_title=key_value),
logical_operator='OR')
key_value = kw.pop('destination_title', None)
if key_value:
kw['destination_title_query'] = ComplexQuery(SimpleQuery(destination_title=key_value),
SimpleQuery(parent_destination_title=key_value),
logical_operator='OR')
key_value = kw.pop('resource_title', None)
if key_value:
kw['resource_title_query'] = ComplexQuery(SimpleQuery(resource_title=key_value),
SimpleQuery(parent_resource_title=key_value),
logical_operator='OR')
task_line_list = context.portal_catalog(
parent_uid = [x.uid for x in task_list],
**kw
)
def sortTaskLine(a, b):
result = cmp(a.getStartDate(), b.getStartDate())
if result == 0:
result = cmp(a.getTitle(), b.getTitle())
return result
if getattr(kw, 'sort_on', None):
def sortTaskLine(a, b):
result = cmp(a.getStartDate(), b.getStartDate())
if result == 0:
result = cmp(a.getTitle(), b.getTitle())
return result
task_line_list.sort(sortTaskLine)
task_line_list.sort(sortTaskLine)
return task_line_list
......@@ -81,8 +81,8 @@
<key> <string>hidden</string> </key>
<value>
<list>
<string>listbox_start_date</string>
<string>listbox_stop_date</string>
<string>listbox_delivery_start_date</string>
<string>listbox_delivery_stop_date</string>
</list>
</value>
</item>
......
......@@ -18,6 +18,7 @@
<string>report_root_list</string>
<string>report_tree</string>
<string>selection_name</string>
<string>sort</string>
<string>sort_columns</string>
<string>title</string>
</list>
......@@ -126,7 +127,7 @@
<string>Task Title</string>
</tuple>
<tuple>
<string>getTranslatedPortalType</string>
<string>translated_portal_type</string>
<string>Type</string>
</tuple>
<tuple>
......@@ -142,11 +143,11 @@
<string>Resource</string>
</tuple>
<tuple>
<string>start_date</string>
<string>delivery.start_date</string>
<string>Begin Date</string>
</tuple>
<tuple>
<string>stop_date</string>
<string>delivery.stop_date</string>
<string>End Date</string>
</tuple>
<tuple>
......@@ -169,11 +170,11 @@
<value>
<list>
<tuple>
<string>start_date</string>
<string>delivery.start_date</string>
<string>Begin Date</string>
</tuple>
<tuple>
<string>stop_date</string>
<string>delivery.stop_date</string>
<string>End Date</string>
</tuple>
</list>
......@@ -198,8 +199,12 @@
<value>
<list>
<tuple>
<string>Task</string>
<string>Task</string>
<string>Task Line</string>
<string>Task Line</string>
</tuple>
<tuple>
<string>Task Report Line</string>
<string>Task Report Line</string>
</tuple>
</list>
</value>
......@@ -228,11 +233,46 @@
<value> <int>0</int> </value>
</item>
<item>
<key> <string>sort_columns</string> </key>
<key> <string>sort</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>sort_columns</string> </key>
<value>
<list>
<tuple>
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>parent_title</string>
<string>Task Title</string>
</tuple>
<tuple>
<string>translated_portal_type</string>
<string>Type</string>
</tuple>
<tuple>
<string>title</string>
<string>Task Line Title</string>
</tuple>
<tuple>
<string>source_title</string>
<string>Assignee</string>
</tuple>
<tuple>
<string>resource_title</string>
<string>Resource</string>
</tuple>
<tuple>
<string>destination_title</string>
<string>Location</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
......
......@@ -16,7 +16,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_start_date</string> </value>
<value> <string>listbox_delivery_start_date</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -16,7 +16,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_stop_date</string> </value>
<value> <string>listbox_delivery_stop_date</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -144,7 +144,7 @@ class TestProject(ERP5TypeTestCase):
# It shows planned tasks also.
task_line_list = project.Project_getSourceProjectRelatedTaskReportList()
self.assertEqual(1, len(task_line_list))
self.assertEqual(task_line_list[0], task.default_task_line)
self.assertEqual(task_line_list[0].getObject(), task.default_task_line)
task.confirm()
self.tic()
......
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