Commit fe72223d authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_project: update related milestone for task

parent 3a585f52
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</chain> </chain>
<chain> <chain>
<type>Task</type> <type>Task</type>
<workflow>delivery_causality_interaction_workflow, delivery_causality_workflow, delivery_simulation_interaction_workflow, edit_workflow, task_workflow</workflow> <workflow>delivery_causality_interaction_workflow, delivery_causality_workflow, delivery_simulation_interaction_workflow, edit_workflow, task_interaction_workflow, task_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Task Line</type> <type>Task Line</type>
......
...@@ -305,6 +305,60 @@ class TestProject(ERP5TypeTestCase): ...@@ -305,6 +305,60 @@ class TestProject(ERP5TypeTestCase):
self.assertEqual(project.project_milestone_1.getQuantityUnit(),'time/day') self.assertEqual(project.project_milestone_1.getQuantityUnit(),'time/day')
self.tic() self.tic()
def testTaskUpdateProjectMilestone(self):
# Create Tasks
task_module = self.getPortalObject().task_module
project = self.getPortalObject().project_module.Project_3
if not project.has_key('project_milestone_task_milestone_1'):
project.newContent(portal_type='Project Milestone', id='project_milestone_task_milestone_1')
if not project.has_key('project_milestone_task_milestone_2'):
project.newContent(portal_type='Project Milestone', id='project_milestone_task_milestone_2')
task_list = []
if not project.project_milestone_task_milestone_1.getPredecessorValueList():
for _ in range(2):
task_list.append(task_module.newContent(
portal_type='Task',
title='Task',
specialise=self.business_process,
task_line_quantity=3,
source_project='project_module/Project_3',
resource='product_module/enterprise_support',
task_line_quantity_unit='time/day',
source='organisation_module/Organisation_1',
source_section='organisation_module/Organisation_1',
destination='organisation_module/Organisation_2',
destination_section='organisation_module/Organisation_2'))
project.project_milestone_task_milestone_1.edit(predecessor_value_list=task_list)
self.tic()
task = task_module.newContent(
portal_type='Task',
title='Task',
specialise=self.business_process,
task_line_quantity=3,
resource='product_module/enterprise_support',
task_line_quantity_unit='time/day',
source='organisation_module/Organisation_1',
source_section='organisation_module/Organisation_1',
destination='organisation_module/Organisation_2',
destination_section='organisation_module/Organisation_2')
task.edit(source_milestone_value = project.project_milestone_task_milestone_1)
self.tic()
predecessor_value_list = project.project_milestone_task_milestone_1.getPredecessorValueList()
self.assertEqual(len(predecessor_value_list), 3)
self.assertTrue(task in predecessor_value_list)
task_milestone_2_length = len(project.project_milestone_task_milestone_2.getPredecessorValueList())
task.edit(source_milestone_value = project.project_milestone_task_milestone_2)
self.tic()
predecessor_value_list = project.project_milestone_task_milestone_1.getPredecessorValueList()
self.assertEqual(len(predecessor_value_list), 2)
self.assertTrue(task not in predecessor_value_list)
predecessor_value_list = project.project_milestone_task_milestone_2.getPredecessorValueList()
self.assertEqual(len(predecessor_value_list), task_milestone_2_length + 1)
self.assertTrue(task in predecessor_value_list)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestProject)) suite.addTest(unittest.makeSuite(TestProject))
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="InteractionWorkflowDefinition" module="Products.ERP5.InteractionWorkflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>creation_guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>task_interaction_workflow</string> </value>
</item>
<item>
<key> <string>manager_bypass</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Task Interaction Workflow</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction" module="Products.ERP5.Interaction"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interactions</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>activate_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>before_commit_script_name</string> </key>
<value>
<list>
<string>Task_updateMilestone</string>
</list>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>update_source_milestone</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<list>
<string>_setSourceMilestone.*</string>
</list>
</value>
</item>
<item>
<key> <string>once_per_transaction</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<list>
<string>Task</string>
</list>
</value>
</item>
<item>
<key> <string>portal_type_group_filter</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>script_name</string> </key>
<value>
<list>
<string>Task_removeForOldMilestone</string>
</list>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Scripts" module="Products.DCWorkflow.Scripts"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>scripts</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
task= state_change['object']
milestone = task.getSourceMilestoneValue()
if milestone:
new_value_list =[x for x in milestone.getPredecessorValueList() if x != task]
milestone.edit(predecessor_value_list=new_value_list)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Task_removeForOldMilestone</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
task= state_change['object']
milestone = task.getSourceMilestoneValue()
if milestone:
new_value_list =[x for x in milestone.getPredecessorValueList() if x != task] + [task]
milestone.edit(predecessor_value_list=new_value_list)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Task_updateMilestone</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Variables" module="Products.DCWorkflow.Variables"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variables</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Worklists" module="Products.DCWorkflow.Worklists"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>worklists</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -20,4 +20,5 @@ Task | delivery_causality_interaction_workflow ...@@ -20,4 +20,5 @@ Task | delivery_causality_interaction_workflow
Task | delivery_causality_workflow Task | delivery_causality_workflow
Task | delivery_simulation_interaction_workflow Task | delivery_simulation_interaction_workflow
Task | edit_workflow Task | edit_workflow
Task | task_interaction_workflow
Task | task_workflow Task | task_workflow
\ No newline at end of file
project_workflow project_workflow
requirement_analysis_workflow requirement_analysis_workflow
task_interaction_workflow
task_report_workflow task_report_workflow
task_workflow task_workflow
\ 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