diff --git a/addons/project/__openerp__.py b/addons/project/__openerp__.py
index 284d69211e4..3177744ea9c 100644
--- a/addons/project/__openerp__.py
+++ b/addons/project/__openerp__.py
@@ -38,6 +38,7 @@ work done on tasks, eso. It is able to render planning, order tasks, eso.
"security/project_security.xml",
"wizard/project_task_delegate_view.xml",
"wizard/project_task_close_view.xml",
+ "wizard/project_task_reevaluate_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 94a7795f586..a3a2d9a5152 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -522,10 +522,11 @@ class task(osv.osv):
self.log(cr, uid, task.id, message)
return True
- def do_reopen(self, cr, uid, ids, *args):
+ def do_reopen(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
request = self.pool.get('res.request')
- tasks = self.browse(cr, uid, ids)
- for task in tasks:
+ for task in self.browse(cr, uid, ids, context=context):
project = task.project_id
if project and project.warn_manager and project.user_id.id and (project.user_id.id != uid):
request.create(cr, uid, {
@@ -672,105 +673,6 @@ class project_work(osv.osv):
project_work()
-class config_compute_remaining(osv.osv_memory):
- _name='config.compute.remaining'
-
- def _get_remaining(self,cr, uid, context=None):
- if context and 'active_id' in context:
- return self.pool.get('project.task').browse(cr, uid, context['active_id'], context=context).remaining_hours
- return False
-
- _columns = {
- 'remaining_hours' : fields.float('Remaining Hours', digits=(16,2), help="Put here the remaining hours required to close the task."),
- 'email':fields.boolean('Email', help="If True then send a email of assigned user and description"),
- }
-
- _defaults = {
- 'remaining_hours': _get_remaining,
- 'email':lambda *a : True,
- }
-
- def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
- users_obj = self.pool.get('res.users')
- obj_tm = users_obj.browse(cr, uid, uid, context).company_id.project_time_mode_id
- tm = obj_tm and obj_tm.name or 'Hours'
-
- res = super(config_compute_remaining, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu=submenu)
-
- 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 f in res['fields']:
- if 'Hours' in res['fields'][f]['string']:
- res['fields'][f]['string'] = res['fields'][f]['string'].replace('Hours',tm)
- return res
-
- def compute_hours(self, cr, uid, ids, context=None):
- data=self.read(cr,uid,ids)[0]
- if context is None:
- context = {}
- task_obj = self.pool.get('project.task')
- request = self.pool.get('res.request')
- user_obj=self.pool.get('res.users')
- if 'active_id' in context:
- user_name = self.pool.get('res.users').browse(cr, uid, uid).name
- description = _("Reopen By ") + user_name + _(" At ") + time.strftime('%Y-%m-%d %H:%M:%S')
- description += "\n" + "=================================" + "\n"
- remaining_hrs = self.browse(cr,uid,ids)[0].remaining_hours
- task_obj.write(cr,uid,context['active_id'],{'remaining_hours':remaining_hrs,'description':description})
- if context.get('button_reactivate', False):
- tasks = task_obj.browse(cr, uid, [context['active_id']], context=context)
- for task in tasks:
- project = task.project_id
- if project and project.warn_manager and project.user_id.id and (project.user_id.id != uid):
- request.create(cr, uid, {
- 'name': _("Task '%s' set in progress") % task.name,
- 'state': 'waiting',
- 'act_from': uid,
- 'act_to': project.user_id.id,
- 'ref_partner_id': task.partner_id.id,
- 'ref_doc1': 'project.task,%d' % task.id,
- 'ref_doc2': 'project.project,%d' % project.id,
- })
- task_obj.write(cr, uid, [task.id], {'state': 'open'})
- if data['email']:
- if not task.user_id.user_email:
- raise osv.except_osv(_('Error'), _("Couldn't send mail because email address is not configured!"))
- else:
- val = {
- 'name': task.name,
- 'user_id': task.user_id.name,
- 'task_id': "%d/%d" % (project.id, task.id),
- 'state': task.state
- }
- subject = "Reopen Task '%s' " % task.name
- user_email= user_obj.browse(cr, uid, uid).address_id.email
- signature=user_obj.browse(cr, uid, uid).signature
- header = (project.warn_header or '') % val
- footer = (project.warn_footer or '') % val
- body = u'%s\n%s\n%s\n\n-- \n%s' % (header, task.description, footer, signature)
- mail_id = email(user_email,[task.user_id.user_email], subject, body.encode('utf-8'), email_bcc=[user_email])
- if not mail_id:
- raise osv.except_osv(_('Error'), _("Couldn't send mail! Check the email ids and smtp configuration settings"))
-
- return {
- 'type': 'ir.actions.act_window_close',
- }
-
-config_compute_remaining()
class account_analytic_account(osv.osv):
_inherit = 'account.analytic.account'
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml
index 926355089b8..421729ccda5 100644
--- a/addons/project/project_view.xml
+++ b/addons/project/project_view.xml
@@ -189,34 +189,6 @@
-
- Compute Remaining Hours
- config.compute.remaining
- form
-
-
-
-
-
-
- Compute Remaining Hours
- ir.actions.act_window
- config.compute.remaining
- form
- form
- new
-
-
project.task.form
@@ -245,7 +217,7 @@
-
+
@@ -264,7 +236,7 @@
-
+
diff --git a/addons/project/wizard/__init__.py b/addons/project/wizard/__init__.py
index 3ce51a80b87..69e1051e621 100644
--- a/addons/project/wizard/__init__.py
+++ b/addons/project/wizard/__init__.py
@@ -21,6 +21,7 @@
import project_task_close
import project_task_delegate
+import project_task_reevaluate
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project/wizard/project_task_close.py b/addons/project/wizard/project_task_close.py
index 55f06f04140..99b6caef308 100644
--- a/addons/project/wizard/project_task_close.py
+++ b/addons/project/wizard/project_task_close.py
@@ -67,6 +67,12 @@ class project_task_close(osv.osv_memory):
res.update({'partner_email': partner.address[0].email})
return res
+ def done(self, cr, uid, ids, context=None):
+ task_pool = self.pool.get('project.task')
+ task_id = context.get('active_id', False)
+ res = task_pool.do_close(cr, uid, [task_id], context=context)
+ return res
+
def confirm(self, cr, uid, ids, context=None):
if context is None:
context = {}
@@ -79,7 +85,7 @@ class project_task_close(osv.osv_memory):
for data in self.browse(cr, uid, ids, context=context):
res = task_pool.do_close(cr, uid, [task.id], context=context)
if res:
- # Send Acknowledgement by Email to Manager and Customer
+ # Send Warn Message by Email to Manager and Customer
if data.manager_warn and not data.manager_email:
raise osv.except_osv(_('Error'), _("Please specify the email address of Project Manager."))
diff --git a/addons/project/wizard/project_task_close_view.xml b/addons/project/wizard/project_task_close_view.xml
index c4cf72fbdd2..9692fe9a733 100644
--- a/addons/project/wizard/project_task_close_view.xml
+++ b/addons/project/wizard/project_task_close_view.xml
@@ -20,9 +20,10 @@
-
+
-
+
+
diff --git a/addons/project/wizard/project_task_reevaluate.py b/addons/project/wizard/project_task_reevaluate.py
new file mode 100644
index 00000000000..e4e2fab66e3
--- /dev/null
+++ b/addons/project/wizard/project_task_reevaluate.py
@@ -0,0 +1,83 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from lxml import etree
+from osv import fields, osv
+from tools.translate import _
+
+class project_task_reevaluate(osv.osv_memory):
+ _name = 'project.task.reevaluate'
+
+ def _get_remaining(self,cr, uid, context=None):
+ if context is None:
+ context = {}
+ active_id = context.get('active_id', False)
+ res = False
+ if active_id:
+ res = self.pool.get('project.task').browse(cr, uid, active_id, context=context).remaining_hours
+ return res
+
+ _columns = {
+ 'remaining_hours' : fields.float('Remaining Hours', digits=(16,2), help="Put here the remaining hours required to close the task."),
+ }
+
+ _defaults = {
+ 'remaining_hours': _get_remaining,
+ }
+
+ def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
+ res = super(project_task_reevaluate, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu=submenu)
+ users_pool = self.pool.get('res.users')
+ time_mode = users_pool.browse(cr, uid, uid, context).company_id.project_time_mode_id
+ time_mode_name = time_mode and time_mode.name or 'Hours'
+ if time_mode_name 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',time_mode_name)
+ return res
+
+ def compute_hours(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
+ data = self.browse(cr, uid, ids, context=context)[0]
+ task_pool = self.pool.get('project.task')
+ task_id = context.get('active_id', False)
+ if task_id:
+ task_pool.write(cr, uid, task_id, {'remaining_hours': data.remaining_hours})
+ if context.get('button_reactivate', False):
+ task_pool.do_reopen(cr, uid, [task_id], context=context)
+ return {}
+project_task_reevaluate()
diff --git a/addons/project/wizard/project_task_reevaluate_view.xml b/addons/project/wizard/project_task_reevaluate_view.xml
new file mode 100644
index 00000000000..5e0e7c89069
--- /dev/null
+++ b/addons/project/wizard/project_task_reevaluate_view.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+ Re-evaluate Task
+ project.task.reevaluate
+ form
+
+
+
+
+
+
+ Re-evaluate Task
+ ir.actions.act_window
+ project.task.reevaluate
+ form
+ form
+ new
+
+
+