diff options
| author | Fabien Pinckaers <fp@tinyerp.com> | 2007-09-07 11:52:33 +0000 |
|---|---|---|
| committer | Fabien Pinckaers <fp@tinyerp.com> | 2007-09-07 11:52:33 +0000 |
| commit | 4c8f67388c7715931b8d226578e2f8ec6277fa48 (patch) | |
| tree | 52221b043a91777f5aed4329d94c4e9ca8e1cd31 /addons/project/wizard/task_delegate.py | |
| parent | 1c47eb23855df61a7ee63af47067afa4189e37eb (diff) | |
Delegation on tasks
bzr revid: fp@tinyerp.com-6eccf820be3e3f0c304232963d7bb871b127a6b3
Diffstat (limited to 'addons/project/wizard/task_delegate.py')
| -rw-r--r-- | addons/project/wizard/task_delegate.py | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/addons/project/wizard/task_delegate.py b/addons/project/wizard/task_delegate.py new file mode 100644 index 00000000000..2143e544cc6 --- /dev/null +++ b/addons/project/wizard/task_delegate.py @@ -0,0 +1,100 @@ +############################################################################## +# +# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import wizard +from tools import email_send as email +import pooler + +ask_form = """<?xml version="1.0" ?> +<form string="Delegate this task to a user"> + <separator string="Delegated Task" colspan="4"/> + <field name="user_id" colspan="4"/> + <field name="planned_hours" colspan="4"/> + <field name="name" colspan="4"/> + <separator string="Validation Task" colspan="4"/> + <field name="planned_hours_me" colspan="4"/> + <field name="prefix" colspan="4"/> + <field name="state" colspan="4"/> +</form>""" + +ask_fields = { + 'name': {'string': 'Title', 'type': 'char', 'required': 'True', 'size':64}, + 'prefix': {'string': 'Prefix of Task', 'type': 'char', 'required': 'True', 'size':64}, + 'user_id': {'string':'Assign To', 'type':'many2one', 'relation': 'res.users', 'required':'True'}, + 'planned_hours': {'string':'Planned Hours', 'type':'float', 'widget':'float_time'}, + 'planned_hours_me': {'string':'Hours to Validate', 'type':'float', 'widget':'float_time'}, + 'state': {'string':'Validation State', 'type':'selection', 'selection': [('pending','Pending'),('done','Done')]}, +} + +class wizard_delegate(wizard.interface): + def _do_assign(self, cr, uid, data, context): + task_obj = pooler.get_pool(cr.dbname).get('project.task') + task = task_obj.browse(cr, uid, data['id'], context) + task_obj.copy(cr, uid, data['id'], { + 'name': data['form']['name'], + 'user_id': data['form']['user_id'], + 'planned_hours': data['form']['planned_hours'], + 'parent_id': data['id'], + 'state': 'open' + }) + task_obj.write(cr, uid, data['id'], { + 'planned_hours': data['form']['planned_hours_me'], + 'name': (data['form']['prefix'] or '')+task.name + }) + if data['form']['state']=='pending': + task_obj.do_pending(cr, uid, [data['id']]) + else: + task_obj.do_close(cr, uid, [data['id']]) + return {} + + def _ask_auto_complete(self, cr, uid, data, context): + task_obj = pooler.get_pool(cr.dbname).get('project.task') + task = task_obj.browse(cr, uid, data['id'], context) + return { + 'name':task.name, + 'user_id': False, + 'planned_hours': task.planned_hours, + 'planned_hours_me': task.planned_hours / 5.0, + 'prefix': 'VALIDATION: ', + 'state': 'pending' + } + + states = { + 'init': { + 'actions': [_ask_auto_complete], + 'result': {'type':'form', 'arch':ask_form, 'fields':ask_fields, 'state':[ + ('end', 'Cancel'), + ('valid', 'Validate') + ]}, + }, + 'valid': { + 'actions': [_do_assign], + 'result': {'type':'state', 'state':'end'}, + } + } +wizard_delegate('project.task.delegate') + |
