summaryrefslogtreecommitdiff
path: root/addons/project/wizard
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2015-05-12 10:49:28 +0200
committerYannick Tivisse <yti@odoo.com>2015-07-08 15:39:02 +0200
commite485b6c5ee25d270ae4d4467b7dcaab18b8fadae (patch)
tree3058e36223b9dc2514c4a7f60d189a9b868db17b /addons/project/wizard
parent55ae657239cb968d438056202ed2acee12b3fba2 (diff)
[IMP] Project : remove task delegation
Conflicts: addons/project/wizard/project_task_delegate.py
Diffstat (limited to 'addons/project/wizard')
-rw-r--r--addons/project/wizard/__init__.py4
-rw-r--r--addons/project/wizard/project_task_delegate.py115
-rw-r--r--addons/project/wizard/project_task_delegate_view.xml47
3 files changed, 0 insertions, 166 deletions
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>