Fix report since that delivery_causality_workflow is added

Change report to display the states by portal type and workflow


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33890 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4b0c4b88
...@@ -55,62 +55,65 @@ ...@@ -55,62 +55,65 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>listbox = []\n <value> <string>listbox = []\n
result_dict = {}\n result_dict = {}\n
translate_state_dict = {}\n
state_dict={}\n
portal_type_dict={}\n
workflow_dict={}\n
portal_workflow = context.portal_workflow\n portal_workflow = context.portal_workflow\n
content_type_list = context.allowedContentTypes()\n content_type_list = context.allowedContentTypes()\n
content_type_list.sort()\n content_type_list.sort()\n
\n \n
translateString = context.Base_translateString\n translateString = context.Base_translateString\n
\n \n
# XXX better implementation is required, but I do not know how to get workflows related to a portal type\n workflow_tool = context.portal_workflow\n
possible_state_name_list = (\'validation_state\',\n for portal_type in content_type_list:\n
\'simulation_state\',\n portal_type_id = portal_type.getId()\n
\'causality_state\',\n workflow_list = workflow_tool.getWorkflowsFor(portal_type_id)\n
\'invoice_state\',\n # Retrieve the workflows by portal_type\n
\'payment_state\',\n for workflow in workflow_list:\n
\'event_state\',\n # not \'edit_workflow\' because state variable is not in catalog\n
\'opportunity_state\',\n if getattr(workflow, \'states\', None) is not None and \\\n
\'immobilisation_state\',)\n workflow.getId() != \'edit_workflow\':\n
\n #retrieve state_var to search in the catalog the states use by the\n
for content_type in content_type_list:\n #workflow\n
content_type_id = content_type.id\n state_var = workflow.state_var\n
for state_name in possible_state_name_list:\n result_list = context.Base_zCountByWorkflowState(portal_type=portal_type_id,\n
result_list = context.Base_zCountByWorkflowState(portal_type=content_type_id,\n state_name=state_var)\n
state_name=state_name)\n
if not ((len(result_list) == 1) and (result_list[0][0] is None)):\n if not ((len(result_list) == 1) and (result_list[0][0] is None)):\n
for result in result_list:\n for result in result_list:\n
portal_type_dict = result_dict.get(content_type_id, {})\n portal_type_dict = result_dict.get(portal_type_id,{})\n
count = portal_type_dict.get(result[0], 0) + result[1]\n workflow_dict = portal_type_dict.get(workflow.title,{})\n
portal_type_dict.update({result[0]: count})\n workflow_dict.update({result[0]:result[1]})\n
result_dict.update({content_type_id: portal_type_dict})\n portal_type_dict.update({workflow.title:workflow_dict})\n
\n result_dict.update({portal_type_id:portal_type_dict})\n
\n # store the title states for the translation\n
def getStateTranslatedTitle(state, portal_type, saved_state_dict=dict()):\n if not translate_state_dict.has_key(result[0]):\n
if state in saved_state_dict:\n state_title = getattr(workflow.states, result[0]).title_or_id()\n
return saved_state_dict[state]\n translate_state_dict[result[0]] = state_title\n
# XXX requires manager proxy role\n
workflow_for_ptype = portal_workflow.getWorkflowsFor(portal_type)\n
for workflow in workflow_for_ptype:\n
if getattr(workflow, \'states\', None) is not None and state in workflow.states.objectIds():\n
saved_state_dict[state] = translateString(getattr(workflow.states, state).title_or_id())\n
return saved_state_dict[state]\n
\n \n
#Display the result\n
state_list_dict = {}\n state_list_dict = {}\n
portal_type_list = result_dict.keys()\n portal_type_list = result_dict.keys()\n
portal_type_list.sort()\n portal_type_list.sort()\n
for portal_type in portal_type_list:\n for portal_type in portal_type_list:\n
listbox.append({\'translated_portal_type\': translateString(portal_type),\n workflow_list = result_dict[portal_type].keys()\n
for workflow_title in workflow_list:\n
listbox.append({\'translated_portal_type\': \'%s - %s\' %\\\n
(translateString(portal_type), translateString(workflow_title)),\n
\'state\' : \'\',\n \'state\' : \'\',\n
\'count\' : \'\'})\n \'count\' : \'\'})\n
state_list = result_dict[portal_type].keys()\n state_list = result_dict[portal_type][workflow_title].keys()\n
state_list.sort()\n state_list.sort()\n
for state in state_list:\n for state in state_list:\n
state_title = getStateTranslatedTitle(state, portal_type)\n result_count = result_dict[portal_type][workflow_title][state]\n
count = state_list_dict.get(state, 0) + result_dict[portal_type][state]\n count = state_list_dict.get(state, 0) + result_count\n
# account the number of items by state\n
state_list_dict.update({state:count})\n state_list_dict.update({state:count})\n
listbox.append({\'translated_portal_type\': \'\',\n listbox.append({\'translated_portal_type\': \'\',\n
\'state\' : state_title,\n \'state\' : translateString(translate_state_dict[state]),\n
\'count\' : result_dict[portal_type][state]})\n \'count\' : result_count})\n
\n \n
#Display the total by state\n
listbox.append({\'translated_portal_type\': translateString(\'All\'),\n listbox.append({\'translated_portal_type\': translateString(\'All\'),\n
\'state\' : \'\',\n \'state\' : \'\',\n
\'count\' : \'\'})\n \'count\' : \'\'})\n
...@@ -118,7 +121,7 @@ state_list = state_list_dict.keys()\n ...@@ -118,7 +121,7 @@ state_list = state_list_dict.keys()\n
state_list.sort()\n state_list.sort()\n
for state in state_list:\n for state in state_list:\n
listbox.append({\'translated_portal_type\': \'\',\n listbox.append({\'translated_portal_type\': \'\',\n
\'state\' : getStateTranslatedTitle(state, None),\n \'state\' : translateString(translate_state_dict[state]),\n
\'count\' : state_list_dict[state]})\n \'count\' : state_list_dict[state]})\n
\n \n
context.Base_updateDialogForm(listbox=listbox, empty_line_number=0)\n context.Base_updateDialogForm(listbox=listbox, empty_line_number=0)\n
...@@ -169,31 +172,37 @@ return context.Folder_viewWorkflowReport()\n ...@@ -169,31 +172,37 @@ return context.Folder_viewWorkflowReport()\n
<tuple> <tuple>
<string>listbox</string> <string>listbox</string>
<string>result_dict</string> <string>result_dict</string>
<string>translate_state_dict</string>
<string>state_dict</string>
<string>portal_type_dict</string>
<string>workflow_dict</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal_workflow</string> <string>portal_workflow</string>
<string>content_type_list</string> <string>content_type_list</string>
<string>translateString</string> <string>translateString</string>
<string>possible_state_name_list</string> <string>workflow_tool</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>content_type</string> <string>portal_type</string>
<string>content_type_id</string> <string>portal_type_id</string>
<string>state_name</string> <string>workflow_list</string>
<string>workflow</string>
<string>getattr</string>
<string>None</string>
<string>state_var</string>
<string>result_list</string> <string>result_list</string>
<string>len</string> <string>len</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>None</string>
<string>result</string> <string>result</string>
<string>portal_type_dict</string> <string>state_title</string>
<string>count</string> <string>_write_</string>
<string>dict</string>
<string>getStateTranslatedTitle</string>
<string>state_list_dict</string> <string>state_list_dict</string>
<string>portal_type_list</string> <string>portal_type_list</string>
<string>portal_type</string> <string>workflow_title</string>
<string>state_list</string> <string>state_list</string>
<string>state</string> <string>state</string>
<string>state_title</string> <string>result_count</string>
<string>count</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
1518 1519
\ No newline at end of file \ No newline at end of file
...@@ -1101,9 +1101,11 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -1101,9 +1101,11 @@ class TestTradeReports(ERP5ReportTestCase):
get_value('default', get_value('default',
render_format='list', REQUEST=self.portal.REQUEST) render_format='list', REQUEST=self.portal.REQUEST)
data_line_list = [l for l in line_list if l.isDataLine()] data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(6, len(data_line_list)) self.assertEquals(8, len(data_line_list))
order_workflow_name = 'Sale Order - Order Workflow'
causality_workflow_name = 'Sale Order - Causality Workflow'
self.checkLineProperties(data_line_list[0], self.checkLineProperties(data_line_list[0],
translated_portal_type='Sale Order') translated_portal_type=order_workflow_name)
self.checkLineProperties(data_line_list[1], self.checkLineProperties(data_line_list[1],
translated_portal_type='', translated_portal_type='',
state='Cancelled', state='Cancelled',
...@@ -1113,15 +1115,21 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -1113,15 +1115,21 @@ class TestTradeReports(ERP5ReportTestCase):
state='Draft', state='Draft',
count=2) count=2)
self.checkLineProperties(data_line_list[3], self.checkLineProperties(data_line_list[3],
translated_portal_type='All') translated_portal_type=causality_workflow_name)
self.checkLineProperties(data_line_list[4], self.checkLineProperties(data_line_list[4],
translated_portal_type='',
state='Draft',
count=3)
self.checkLineProperties(data_line_list[5],
translated_portal_type='All')
self.checkLineProperties(data_line_list[6],
translated_portal_type='', translated_portal_type='',
state='Cancelled', state='Cancelled',
count=1) count=1)
self.checkLineProperties(data_line_list[5], self.checkLineProperties(data_line_list[7],
translated_portal_type='', translated_portal_type='',
state='Draft', state='Draft',
count=2) count=5)
def test_suite(): def test_suite():
......
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