diff options
| author | Yannick Tivisse <yti@odoo.com> | 2015-05-12 10:49:28 +0200 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2015-07-08 15:39:02 +0200 |
| commit | e485b6c5ee25d270ae4d4467b7dcaab18b8fadae (patch) | |
| tree | 3058e36223b9dc2514c4a7f60d189a9b868db17b /addons/project | |
| parent | 55ae657239cb968d438056202ed2acee12b3fba2 (diff) | |
[IMP] Project : remove task delegation
Conflicts:
addons/project/wizard/project_task_delegate.py
Diffstat (limited to 'addons/project')
| -rw-r--r-- | addons/project/__init__.py | 1 | ||||
| -rw-r--r-- | addons/project/__openerp__.py | 1 | ||||
| -rw-r--r-- | addons/project/project.py | 58 | ||||
| -rw-r--r-- | addons/project/project_view.xml | 16 | ||||
| -rw-r--r-- | addons/project/res_config.py | 3 | ||||
| -rw-r--r-- | addons/project/res_config_view.xml | 4 | ||||
| -rw-r--r-- | addons/project/security/project_security.xml | 5 | ||||
| -rw-r--r-- | addons/project/tests/test_project_flow.py | 9 | ||||
| -rw-r--r-- | addons/project/wizard/__init__.py | 4 | ||||
| -rw-r--r-- | addons/project/wizard/project_task_delegate.py | 115 | ||||
| -rw-r--r-- | addons/project/wizard/project_task_delegate_view.xml | 47 |
11 files changed, 0 insertions, 263 deletions
diff --git a/addons/project/__init__.py b/addons/project/__init__.py index 81f4e5554ed..433a751190b 100644 --- a/addons/project/__init__.py +++ b/addons/project/__init__.py @@ -4,7 +4,6 @@ import project import company import report -import wizard import res_partner import res_config import web_planner diff --git a/addons/project/__openerp__.py b/addons/project/__openerp__.py index 784fe4b6be4..6976292f226 100644 --- a/addons/project/__openerp__.py +++ b/addons/project/__openerp__.py @@ -37,7 +37,6 @@ Dashboard / Reports for Project Management will include: """, 'data': [ 'security/project_security.xml', - 'wizard/project_task_delegate_view.xml', 'security/ir.model.access.csv', 'project_data.xml', 'project_view.xml', diff --git a/addons/project/project.py b/addons/project/project.py index 42f3a051a06..ab715b0a2fc 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -591,7 +591,6 @@ class task(osv.osv): 'planned_hours': fields.float('Initially Planned Hours', help='Estimated time to do the task, usually set by the project manager when the task is in draft state.'), 'remaining_hours': fields.float('Remaining Hours', digits=(16,2), help="Total remaining time, can be re-estimated periodically by the assignee of the task."), 'user_id': fields.many2one('res.users', 'Assigned to', select=True, track_visibility='onchange'), - 'delegated_user_id': fields.related('child_ids', 'user_id', type='many2one', relation='res.users', string='Delegated To'), 'partner_id': fields.many2one('res.partner', 'Customer'), 'manager_id': fields.related('project_id', 'analytic_account_id', 'user_id', type='many2one', relation='res.users', string='Project Manager'), 'company_id': fields.many2one('res.company', 'Company'), @@ -757,63 +756,6 @@ class task(osv.osv): raise UserError(_("Child task still open.\nPlease cancel or complete child task first.")) return True - def _delegate_task_attachments(self, cr, uid, task_id, delegated_task_id, context=None): - attachment = self.pool.get('ir.attachment') - attachment_ids = attachment.search(cr, uid, [('res_model', '=', self._name), ('res_id', '=', task_id)], context=context) - new_attachment_ids = [] - for attachment_id in attachment_ids: - new_attachment_ids.append(attachment.copy(cr, uid, attachment_id, default={'res_id': delegated_task_id}, context=context)) - return new_attachment_ids - - def _prepare_delegate_values(self, cr, uid, ids, delegate_data, context=None): - delegate_values = {} - for task in self.browse(cr, uid, ids, context=context): - delegate_values[task.id] = { - 'name': delegate_data['name'], - 'project_id': delegate_data['project_id'] and delegate_data['project_id'][0] or False, - 'stage_id': delegate_data.get('stage_id') and delegate_data.get('stage_id')[0] or False, - 'user_id': delegate_data['user_id'] and delegate_data['user_id'][0] or False, - 'planned_hours': delegate_data['planned_hours'] or 0.0, - 'parent_ids': [(6, 0, [task.id])], - 'description': delegate_data['new_task_description'] or '', - 'child_ids': [], - 'remaining_hours': delegate_data['planned_hours_me'], - # The values below will be written on the old task. - 'task_planned_hours': delegate_data['planned_hours_me'], - 'task_name': delegate_data['prefix'] or '' - } - return delegate_values - - def do_delegate(self, cr, uid, ids, delegate_data=None, context=None): - """ - Delegate Task to another users. - """ - if delegate_data is None: - delegate_data = {} - assert delegate_data['user_id'], _("Delegated User should be specified") - delegated_tasks = {} - vals = self._prepare_delegate_values(cr, uid, ids, delegate_data, context) - for task in self.browse(cr, uid, ids, context=context): - - delegated_task_id = self.copy(cr, uid, task.id, { - 'name': vals[task.id]['name'], - 'project_id': vals[task.id]['project_id'], - 'stage_id': vals[task.id]['stage_id'], - 'user_id': vals[task.id]['user_id'], - 'planned_hours': vals[task.id]['planned_hours'], - 'parent_ids': vals[task.id]['parent_ids'], - 'description': vals[task.id]['description'], - 'child_ids': vals[task.id]['child_ids'], - }, context=context) - self._delegate_task_attachments(cr, uid, task.id, delegated_task_id, context=context) - - task.write({ - 'remaining_hours': vals[task.id]['remaining_hours'], - 'planned_hours': vals[task.id]['task_planned_hours'], - 'name': vals[task.id]['task_name'] - }, context=context) - delegated_tasks[task.id] = delegated_task_id - return delegated_tasks def _store_history(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids, context=context): diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index df9a3efb76b..2c1d5dcada6 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -290,21 +290,6 @@ <field name="description" type="html"/> <div class="oe_clear"/> </page> - <page string="Delegation" groups="project.group_delegate_task"> - <button name="%(action_project_task_delegate)d" string="Delegate" type="action" - groups="project.group_delegate_task"/> - <separator string="Parent Tasks"/> - <field name="parent_ids"/> - <separator string="Delegated tasks"/> - <field name="child_ids"> - <tree name="delegated_task" string="Delegated tasks"> - <field name="name"/> - <field name="user_id"/> - <field name="stage_id"/> - <field name="date_deadline"/> - </tree> - </field> - </page> <page string="Extra Info"> <group col="4"> <field name="sequence" groups="base.group_no_one"/> @@ -410,7 +395,6 @@ <field name="name"/> <field name="project_id" invisible="context.get('user_invisible', False)"/> <field name="user_id" invisible="context.get('user_invisible', False)"/> - <field name="delegated_user_id" invisible="context.get('show_delegated', True)"/> <field name="planned_hours" invisible="context.get('set_visible',False)" groups="project.group_time_work_estimation_tasks"/> <field name="date_deadline" invisible="context.get('deadline_visible',True)"/> <field name="stage_id" invisible="context.get('set_visible',False)"/> diff --git a/addons/project/res_config.py b/addons/project/res_config.py index 661dbe32281..1f43125d171 100644 --- a/addons/project/res_config.py +++ b/addons/project/res_config.py @@ -40,9 +40,6 @@ class project_configuration(osv.osv_memory): 'group_time_work_estimation_tasks': fields.boolean("Manage time estimation on tasks", implied_group='project.group_time_work_estimation_tasks', help="Allows you to compute Time Estimation on tasks."), - 'group_manage_delegation_task': fields.boolean("Allow task delegation", - implied_group='project.group_delegate_task', - help="Allows you to delegate tasks to other users."), 'generate_project_alias': fields.boolean("Automatically generate an email alias at the project creation", help="Odoo will generate an email alias at the project creation from project name."), } diff --git a/addons/project/res_config_view.xml b/addons/project/res_config_view.xml index 05c5e4bc42b..7547bb90161 100644 --- a/addons/project/res_config_view.xml +++ b/addons/project/res_config_view.xml @@ -40,10 +40,6 @@ <field name="module_pad" class="oe_inline"/> <label for="module_pad"/> </div> - <div> - <field name="group_manage_delegation_task" class="oe_inline"/> - <label for="group_manage_delegation_task"/> - </div> </div> </group> <group> diff --git a/addons/project/security/project_security.xml b/addons/project/security/project_security.xml index 5cf56caa8d8..e1d8eb71b0a 100644 --- a/addons/project/security/project_security.xml +++ b/addons/project/security/project_security.xml @@ -26,11 +26,6 @@ <field name="category_id" ref="base.module_category_hidden"/> </record> - <record id="group_delegate_task" model="res.groups"> - <field name="name">Task Delegation</field> - <field name="category_id" ref="base.module_category_hidden"/> - </record> - </data> <data noupdate="1"> diff --git a/addons/project/tests/test_project_flow.py b/addons/project/tests/test_project_flow.py index e753687e00d..d053f2213d3 100644 --- a/addons/project/tests/test_project_flow.py +++ b/addons/project/tests/test_project_flow.py @@ -103,12 +103,3 @@ class TestProjectFlow(TestProjectBase): self.assertEqual(task.name, 'Frogs', 'project_task: name should be the email subject') self.assertEqual(task.project_id.id, self.project_pigs.id, 'project_task: incorrect project') self.assertEqual(task.stage_id.sequence, 1, 'project_task: should have a stage with sequence=1') - # Open the delegation wizard - self.env['project.task.delegate'].with_context({ - 'active_id': task.id}).sudo(self.user_projectuser).create({ - 'user_id': self.user_projectuser.id, - 'planned_hours': 12.0, - 'planned_hours_me': 2.0, - }).with_context({'active_id': task.id}).delegate() - # Check delegation details - self.assertEqual(task.planned_hours, 2, 'project_task_delegate: planned hours is not correct after delegation') diff --git a/addons/project/wizard/__init__.py b/addons/project/wizard/__init__.py deleted file mode 100644 index 2f548350c04..00000000000 --- a/addons/project/wizard/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -import project_task_delegate diff --git a/addons/project/wizard/project_task_delegate.py b/addons/project/wizard/project_task_delegate.py deleted file mode 100644 index 8e4582d275a..00000000000 --- a/addons/project/wizard/project_task_delegate.py +++ /dev/null @@ -1,115 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from lxml import etree - -from openerp import tools -from openerp.tools.translate import _ -from openerp.osv import fields, osv - -class project_task_delegate(osv.osv_memory): - _name = 'project.task.delegate' - _description = 'Task Delegate' - - _columns = { - 'name': fields.char('Delegated Title', required=True, help="New title of the task delegated to the user"), - 'prefix': fields.char('Your Task Title', 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.html('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', 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 - """ - res = super(project_task_delegate, self).default_get(cr, uid, fields, context=context) - 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['project_id'] = int(task.project_id.id) if task.project_id else False - - if 'name' in fields: - if task_name.startswith(_('CHECK: ')): - newname = tools.ustr(task_name).replace(_('CHECK: '), '') - else: - newname = tools.ustr(task_name or '') - res['name'] = newname - if 'planned_hours' in fields: - res['planned_hours'] = task.remaining_hours or 0.0 - if 'prefix' in fields: - if task_name.startswith(_('CHECK: ')): - newname = tools.ustr(task_name).replace(_('CHECK: '), '') - else: - newname = tools.ustr(task_name or '') - prefix = _('CHECK: %s') % newname - res['prefix'] = prefix - if 'new_task_description' in fields: - res['new_task_description'] = task.description - return res - - - _defaults = { - 'planned_hours_me': 1.0, - 'state': 'pending', - } - - def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): - res = super(project_task_delegate, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) - users_pool = self.pool.get('res.users') - obj_tm = users_pool.browse(cr, uid, uid, context=context).company_id.project_time_mode_id - tm = obj_tm and obj_tm.name or 'Hours' - if tm in ['Hours','Hour']: - return res - - eview = etree.fromstring(res['arch']) - def _check_rec(eview): - if eview.attrib.get('widget','') == 'float_time': - eview.set('widget','float') - for child in eview: - _check_rec(child) - return True - - _check_rec(eview) - res['arch'] = etree.tostring(eview) - for field in res['fields']: - if 'Hours' in res['fields'][field]['string']: - res['fields'][field]['string'] = res['fields'][field]['string'].replace('Hours',tm) - return res - - def delegate(self, cr, uid, ids, context=None): - if context is None: - context = {} - task_id = context.get('active_id', False) - task_pool = self.pool.get('project.task') - delegate_data = self.read(cr, uid, ids, context=context)[0] - 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[action_model].read(cr, uid, [action_id], context=context)[0] - 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 diff --git a/addons/project/wizard/project_task_delegate_view.xml b/addons/project/wizard/project_task_delegate_view.xml deleted file mode 100644 index 9b9173eb5d8..00000000000 --- a/addons/project/wizard/project_task_delegate_view.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data> - - <record id="view_project_task_delegate" model="ir.ui.view"> - <field name="name">Project Task Delegate</field> - <field name="model">project.task.delegate</field> - <field name="arch" type="xml"> - <form string="Project Task Delegate"> - <group> - <group> - <field name="project_id" on_change="onchange_project_id(project_id)"/> - <separator string="Delegated Task" colspan="2"/> - <field name="name"/> - <field name="planned_hours"/> - <separator string="New Task Description" colspan="2"/> - <field name="new_task_description" colspan="2" nolabel="1"/> - </group> - <group> - <field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'project.group_project_user']}"/> - <separator string="Validation Task" colspan="2"/> - <field name="prefix" string="Validation Task Title"/> - <field name="planned_hours_me"/> - <field name="state"/> - </group> - </group> - <footer> - <button name="delegate" string="_Delegate" type="object" class="oe_highlight"/> - or - <button string="Cancel" class="oe_link" special="cancel" /> - </footer> - </form> - </field> - </record> - - <record id="action_project_task_delegate" model="ir.actions.act_window"> - <field name="name">Project Task Delegate</field> - <field name="type">ir.actions.act_window</field> - <field name="res_model">project.task.delegate</field> - <field name="view_type">form</field> - <field name="view_mode">form</field> - <field name="view_id" ref="view_project_task_delegate"/> - <field name="target">new</field> - </record> - - </data> -</openerp> |
