summaryrefslogtreecommitdiff
path: root/addons/project/wizard
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2011-11-18 12:22:26 +0530
committerAntony Lesuisse <al@openerp.com>2011-11-18 12:22:26 +0530
commit3bf9a110213fbf93cb6ab9e83e18860551fbd52b (patch)
tree57e4a6957eeda0ad191d9a551da35201e464fea3 /addons/project/wizard
parentab2bb4bdda6b0c6b526a7ee64547d8cfc0ed1313 (diff)
parentbe1d64f860b3d906b9677306ff0577d43dbe3e9d (diff)
[MERGE] allow to delegate into an other project
bzr revid: al@openerp.com-20111118065226-yaaynguc59oxs84n
Diffstat (limited to 'addons/project/wizard')
-rw-r--r--addons/project/wizard/project_task_delegate.py36
-rw-r--r--addons/project/wizard/project_task_delegate_view.xml14
2 files changed, 36 insertions, 14 deletions
diff --git a/addons/project/wizard/project_task_delegate.py b/addons/project/wizard/project_task_delegate.py
index eaf5dea3084..0b4457d5e7f 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'}
+ delegated_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'] = delegated_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()
diff --git a/addons/project/wizard/project_task_delegate_view.xml b/addons/project/wizard/project_task_delegate_view.xml
index f9b27af05b3..072325c2b53 100644
--- a/addons/project/wizard/project_task_delegate_view.xml
+++ b/addons/project/wizard/project_task_delegate_view.xml
@@ -8,18 +8,19 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Project Task Delegate">
+ <field name="project_id" on_change="onchange_project_id(project_id)"/>
+ <field name="user_id"/>
<group colspan="2" col="2">
<separator string="Delegated Task" colspan="4"/>
- <field name="user_id" colspan="4"/>
- <field name="planned_hours" widget="float_time" colspan="4"/>
- <field name="name" colspan="4"/>
+ <field name="name"/>
+ <field name="planned_hours"/>
<separator string="New Task Description" colspan="4"/>
- <field name="new_task_description" colspan="4" nolabel="1"/>
+ <field name="new_task_description" colspan="4" nolabel="1"/>
</group>
<group colspan="2" col="2">
<separator string="Validation Task" colspan="4"/>
- <field name="planned_hours_me" widget="float_time" colspan="4"/>
- <field name="prefix" string="Validation Task Title" colspan="4"/>
+ <field name="prefix" string="Validation Task Title"/>
+ <field name="planned_hours_me"/>
<field name="state" colspan="4"/>
</group>
<separator string="" colspan="4"/>
@@ -40,7 +41,6 @@
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_project_task_delegate"/>
- <field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>