summaryrefslogtreecommitdiff
path: root/addons/project
diff options
context:
space:
mode:
authorHarry (OpenERP) <hmo@tinyerp.com>2011-02-22 10:57:39 +0530
committerHarry (OpenERP) <hmo@tinyerp.com>2011-02-22 10:57:39 +0530
commit2effe90a19ed94a652b3367bcb9d3e42ef0fcbbc (patch)
treed606181554a75293638a8af4ef94b856367e4ec3 /addons/project
parentda05e220826b2c52ef1448454674d8e27b8e8b0b (diff)
parent91c1768528c3ae07305bf5cf460b40bd1b9b6c00 (diff)
[MERGE] merged from trunk-addons-development branch
bzr revid: hmo@tinyerp.com-20110222052739-jjyzcrqv0pr29qwq
Diffstat (limited to 'addons/project')
-rw-r--r--addons/project/project.py19
-rw-r--r--addons/project/wizard/project_task_close.py12
-rw-r--r--addons/project/wizard/project_task_delegate.py8
3 files changed, 20 insertions, 19 deletions
diff --git a/addons/project/project.py b/addons/project/project.py
index bff63746d9a..3828820b20d 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -134,22 +134,13 @@ class project(osv.osv):
'project.project': (lambda self, cr, uid, ids, c={}: ids, ['tasks'], 10),
'project.task': (_get_project_task, ['planned_hours', 'effective_hours', 'remaining_hours', 'total_hours', 'progress', 'delay_hours','state'], 10),
}),
- 'effective_hours': fields.function(_progress_rate, multi="progress", method=True, string='Time Spent', help="Sum of spent hours of all tasks related to this project and its child projects.",
- store = {
- 'project.project': (lambda self, cr, uid, ids, c={}: ids, ['tasks'], 10),
- 'project.task': (_get_project_task, ['planned_hours', 'effective_hours', 'remaining_hours', 'total_hours', 'progress', 'delay_hours','state'], 10),
- }),
+ 'effective_hours': fields.function(_progress_rate, multi="progress", method=True, string='Time Spent', help="Sum of spent hours of all tasks related to this project and its child projects."),
'total_hours': fields.function(_progress_rate, multi="progress", method=True, string='Total Time', help="Sum of total hours of all tasks related to this project and its child projects.",
store = {
'project.project': (lambda self, cr, uid, ids, c={}: ids, ['tasks'], 10),
'project.task': (_get_project_task, ['planned_hours', 'effective_hours', 'remaining_hours', 'total_hours', 'progress', 'delay_hours','state'], 10),
}),
- 'progress_rate': fields.function(_progress_rate, multi="progress", method=True, string='Progress', type='float', group_operator="avg", help="Percent of tasks closed according to the total of tasks todo.",
- store = {
- 'project.project': (lambda self, cr, uid, ids, c={}: ids, ['tasks'], 10),
- 'project.task': (_get_project_task, ['planned_hours', 'effective_hours', 'remaining_hours', 'total_hours', 'progress', 'delay_hours','state'], 10),
- 'project.task.work': (_get_project_work, ['hours'], 10),
- }),
+ 'progress_rate': fields.function(_progress_rate, multi="progress", method=True, string='Progress', type='float', group_operator="avg", help="Percent of tasks closed according to the total of tasks todo."),
'warn_customer': fields.boolean('Warn Partner', help="If you check this, the user will have a popup when closing a task that propose a message to send by email to the customer.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),
'warn_header': fields.text('Mail Header', help="Header added at the beginning of the email for the warning message sent to the customer when a task is closed.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),
'warn_footer': fields.text('Mail Footer', help="Footer added at the beginning of the email for the warning message sent to the customer when a task is closed.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),
@@ -239,6 +230,7 @@ class project(osv.osv):
start_date = date(*time.strptime(proj.date_start,'%Y-%m-%d')[:3])
end_date = date(*time.strptime(proj.date,'%Y-%m-%d')[:3])
new_date_end = (datetime(*time.strptime(new_date_start,'%Y-%m-%d')[:3])+(end_date-start_date)).strftime('%Y-%m-%d')
+ context.update({'copy':True})
new_id = project_obj.copy(cr, uid, proj.id, default = {
'name': proj.name +_(' (copy)'),
'state':'open',
@@ -365,7 +357,10 @@ class task(osv.osv):
default['active'] = True
default['type_id'] = False
if not default.get('name', False):
- default['name'] = self.browse(cr, uid, id, context=context).name
+ default['name'] = self.browse(cr, uid, id, context=context).name or ''
+ if not context.get('copy',False):
+ new_name = _("%s (copy)")%default.get('name','')
+ default.update({'name':new_name})
return super(task, self).copy_data(cr, uid, id, default, context)
def _check_dates(self, cr, uid, ids, context=None):
diff --git a/addons/project/wizard/project_task_close.py b/addons/project/wizard/project_task_close.py
index 0657888ccb4..589dd2df007 100644
--- a/addons/project/wizard/project_task_close.py
+++ b/addons/project/wizard/project_task_close.py
@@ -22,7 +22,7 @@
from osv import fields, osv
import tools
from tools.translate import _
-
+import re
class project_task_close(osv.osv_memory):
"""
Close Task
@@ -100,8 +100,14 @@ class project_task_close(osv.osv_memory):
}
to_adr = []
- header = (project.warn_header or '') % val
- footer = (project.warn_footer or '') % val
+ header = footer = ''
+ try:
+ header_str = (project.warn_header or '')
+ footer_str = (project.warn_footer or '')
+ header = (re.sub(r'\%\W*\(', '%(', header_str)) % val
+ footer = (re.sub(r'\%\W*\(', '%(', footer_str)) % val
+ except:
+ raise osv.except_osv(_('Error'), _("Invlaid automatic variables used in project header or foooter."))
body = u'%s\n%s\n%s\n\n-- \n%s' % (header, task.description, footer, signature)
if data.manager_warn and data.manager_email:
to_adr.append(data.manager_email)
diff --git a/addons/project/wizard/project_task_delegate.py b/addons/project/wizard/project_task_delegate.py
index 72b32f7db68..99dfa3b4d5a 100644
--- a/addons/project/wizard/project_task_delegate.py
+++ b/addons/project/wizard/project_task_delegate.py
@@ -53,17 +53,17 @@ class project_task_delegate(osv.osv_memory):
if 'name' in fields:
if task_name.startswith(_('CHECK: ')):
- newname = str(task_name).replace(_('CHECK: '), '')
+ newname = tools.ustr(task_name).replace(_('CHECK: '), '')
else:
- newname = task_name or ''
+ newname = tools.ustr(task_name or '')
res.update({'name': newname})
if 'planned_hours' in fields:
res.update({'planned_hours': task.remaining_hours or 0.0})
if 'prefix' in fields:
if task_name.startswith(_('CHECK: ')):
- newname = str(task_name).replace(_('CHECK: '), '')
+ newname = tools.ustr(task_name).replace(_('CHECK: '), '')
else:
- newname = task_name or ''
+ newname = tools.ustr(task_name or '')
prefix = _('CHECK: ') + newname
res.update({'prefix': prefix})
if 'new_task_description' in fields: