[FIX] project: when delegrated user close task, parent task should reopen if pending

bzr revid: hmo@tinyerp.com-20100208071656-o2omd39a55oycx8p
This commit is contained in:
Harry (Open ERP) 2010-02-08 12:46:56 +05:30
parent f86e18f3fd
commit e0bdc84806
2 changed files with 12 additions and 10 deletions

View File

@ -371,13 +371,14 @@ class task(osv.osv):
'ref_doc2': 'project.project,%d'% (project.id,),
})
self.write(cr, uid, [task.id], {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
if task.parent_ids and task.parent_ids.state in ('pending','draft'):
reopen = True
for child in task.parent_ids.child_ids:
if child.id != task.id and child.state not in ('done','cancelled'):
reopen = False
if reopen:
self.do_reopen(cr, uid, [task.parent_ids.id])
for parent_id in task.parent_ids:
if parent_id.state in ('pending','draft'):
reopen = True
for child in parent_id.child_ids:
if child.id != task.id and child.state not in ('done','cancelled'):
reopen = False
if reopen:
self.do_reopen(cr, uid, [parent_id.id])
return True
def do_reopen(self, cr, uid, ids, *args):

View File

@ -52,12 +52,12 @@ class wizard_delegate(wizard.interface):
task_obj = pooler.get_pool(cr.dbname).get('project.task')
task = task_obj.browse(cr, uid, data['id'], context)
newname = data['form']['prefix'] or ''
task_obj.copy(cr, uid, data['id'], {
new_task_id = task_obj.copy(cr, uid, data['id'], {
'name': data['form']['name'],
'user_id': data['form']['user_id'],
'planned_hours': data['form']['planned_hours'],
'remaining_hours': data['form']['planned_hours'],
'parent_id': data['id'],
'parent_ids': [(6, 0, [data['id']])],
'state': 'open',
'description': data['form']['new_task_description'] or '',
'child_ids': [],
@ -65,7 +65,8 @@ class wizard_delegate(wizard.interface):
})
task_obj.write(cr, uid, [data['id']], {
'remaining_hours': data['form']['planned_hours_me'],
'name': newname
'name': newname,
'child_ids': [(6, 0, [new_task_id])]
})
if data['form']['state']=='pending':
task_obj.do_pending(cr, uid, [data['id']])