summaryrefslogtreecommitdiff
path: root/addons/project/wizard/project_task_delegate.py
diff options
context:
space:
mode:
authorHarry (OpenERP) <hmo@tinyerp.com>2011-11-17 20:39:14 +0530
committerHarry (OpenERP) <hmo@tinyerp.com>2011-11-17 20:39:14 +0530
commitbe1d64f860b3d906b9677306ff0577d43dbe3e9d (patch)
treebbed77e0a9ccedf2eba26f27e503b097089d43f8 /addons/project/wizard/project_task_delegate.py
parentbf99648acc80cf7c1ee320ce23f95527b3e9d7c8 (diff)
[IMP] project: added new field "project_id" on delegrate wizard and refactor stuff of delegrate action
bzr revid: hmo@tinyerp.com-20111117150914-hkzrttoe3e2wzuvo
Diffstat (limited to 'addons/project/wizard/project_task_delegate.py')
-rw-r--r--addons/project/wizard/project_task_delegate.py36
1 files changed, 29 insertions, 7 deletions
diff --git a/addons/project/wizard/project_task_delegate.py b/addons/project/wizard/project_task_delegate.py
index eaf5dea3084..4b8da00dc10 100644
--- a/addons/project/wizard/project_task_delegate.py
+++ b/addons/project/wizard/project_task_delegate.py
@@ -31,14 +31,23 @@ class project_task_delegate(osv.osv_memory):
_columns = {
'name': fields.char('Delegated Title', size=64, required=True, help="New title of the task delegated to the user"),
- 'prefix': fields.char('Your Task Title', size=64, required=True, help="Title for your validation task"),
+ 'prefix': fields.char('Your Task Title', size=64, help="Title for your validation task"),
+ 'project_id': fields.many2one('project.project', 'Project', help="User you want to delegate this task to"),
'user_id': fields.many2one('res.users', 'Assign To', required=True, help="User you want to delegate this task to"),
'new_task_description': fields.text('New Task Description', help="Reinclude the description of the task in the task of the user"),
'planned_hours': fields.float('Planned Hours', help="Estimated time to close this task by the delegated user"),
- 'planned_hours_me': fields.float('Hours to Validate', required=True, help="Estimated time for you to validate the work done by the user to whom you delegate this task"),
- 'state': fields.selection([('pending','Pending'), ('done','Done'), ], 'Validation State', required=True, help="New state of your own task. Pending will be reopened automatically when the delegated task is closed")
+ 'planned_hours_me': fields.float('Hours to Validate', help="Estimated time for you to validate the work done by the user to whom you delegate this task"),
+ 'state': fields.selection([('pending','Pending'), ('done','Done'), ], 'Validation State', help="New state of your own task. Pending will be reopened automatically when the delegated task is closed")
}
+ def onchange_project_id(self, cr, uid, ids, project_id=False, context=None):
+ project_project = self.pool.get('project.project')
+ if not project_id:
+ return {'value':{'user_id': False}}
+ project = project_project.browse(cr, uid, project_id, context=context)
+ return {'value': {'user_id': project.user_id and project.user_id.id or False}}
+
+
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
@@ -47,10 +56,15 @@ class project_task_delegate(osv.osv_memory):
if context is None:
context = {}
record_id = context and context.get('active_id', False) or False
+ if not record_id:
+ return res
task_pool = self.pool.get('project.task')
task = task_pool.browse(cr, uid, record_id, context=context)
task_name =tools.ustr(task.name)
+ if 'project_id' in fields:
+ res.update({'project_id': task.project_id and task.project_id.id})
+
if 'name' in fields:
if task_name.startswith(_('CHECK: ')):
newname = tools.ustr(task_name).replace(_('CHECK: '), '')
@@ -105,9 +119,17 @@ class project_task_delegate(osv.osv_memory):
task_id = context.get('active_id', False)
task_pool = self.pool.get('project.task')
delegate_data = self.read(cr, uid, ids, context=context)[0]
- delegate_data['user_id'] = delegate_data['user_id'][0]
- delegate_data['name'] = tools.ustr(delegate_data['name'])
- task_pool.do_delegate(cr, uid, task_id, delegate_data, context=context)
- return {'type': 'ir.actions.act_window_close'}
+ delegrated_tasks = task_pool.do_delegate(cr, uid, [task_id], delegate_data, context=context)
+ models_data = self.pool.get('ir.model.data')
+
+ action_model, action_id = models_data.get_object_reference(cr, uid, 'project', 'action_view_task')
+ view_model, task_view_form_id = models_data.get_object_reference(cr, uid, 'project', 'view_task_form2')
+ view_model, task_view_tree_id = models_data.get_object_reference(cr, uid, 'project', 'view_task_tree2')
+ action = self.pool.get(action_model).read(cr, uid, action_id, context=context)
+ action['res_id'] = delegrated_tasks[task_id]
+ action['view_id'] = False
+ action['views'] = [(task_view_form_id, 'form'), (task_view_tree_id, 'tree')]
+ action['help'] = False
+ return action
project_task_delegate()