diff --git a/addons/project/__openerp__.py b/addons/project/__openerp__.py
index b0e3880c243..284d69211e4 100644
--- a/addons/project/__openerp__.py
+++ b/addons/project/__openerp__.py
@@ -31,14 +31,13 @@
work done on tasks, eso. It is able to render planning, order tasks, eso.
Dashboard for project members that includes:
* List of my open tasks
- * List of messages
* Members list of project
- * Issues
""",
"init_xml": [],
"update_xml": [
"security/project_security.xml",
"wizard/project_task_delegate_view.xml",
+ "wizard/project_task_close_view.xml",
"security/ir.model.access.csv",
"project_data.xml",
"project_view.xml",
@@ -46,7 +45,6 @@ work done on tasks, eso. It is able to render planning, order tasks, eso.
"project_installer.xml",
"res_partner_view.xml",
"report/project_report_view.xml",
- "wizard/project_close_task_view.xml",
"board_project_view.xml",
'board_project_manager_view.xml'
],
diff --git a/addons/project/project.py b/addons/project/project.py
index dfba5cc46c2..94a7795f586 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -487,18 +487,17 @@ class task(osv.osv):
res['fields'][f]['string'] = res['fields'][f]['string'].replace('Hours',tm)
return res
- def do_close(self, cr, uid, ids, *args):
- mail_send = False
- mod_obj = self.pool.get('ir.model.data')
- request = self.pool.get('res.request')
- tasks = self.browse(cr, uid, ids)
- task_id = ids[0]
- cntx = {}
- if len(args):
- cntx = args[0]
- for task in tasks:
+ def do_close(self, cr, uid, ids, context=None):
+ """
+ Close Task
+ """
+ if context is None:
+ context = {}
+ request_pool = self.pool.get('res.request')
+ for task in self.browse(cr, uid, ids, context=context):
project = task.project_id
if project:
+ # Send request to project manager
if project.warn_manager and project.user_id and (project.user_id.id != uid):
request.create(cr, uid, {
'name': _("Task '%s' closed") % task.name,
@@ -509,12 +508,7 @@ class task(osv.osv):
'ref_doc1': 'project.task,%d'% (task.id,),
'ref_doc2': 'project.project,%d'% (project.id,),
})
- elif (project.warn_manager or project.warn_customer) and cntx.get('mail_send',True):
- cntx.update({'send_manager': project.warn_manager, 'send_partner': project.warn_customer})
- mail_send = True
- message = _('Task ') + " '" + task.name + "' "+ _("is Done.")
- self.log(cr, uid, task.id, message)
-
+
for parent_id in task.parent_ids:
if parent_id.state in ('pending','draft'):
reopen = True
@@ -523,24 +517,10 @@ class task(osv.osv):
reopen = False
if reopen:
self.do_reopen(cr, uid, [parent_id.id])
- if mail_send:
- model_data_ids = mod_obj.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_project_close_task')])
- resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
- cntx.update({'task_id': task_id})
- return {
- 'name': _('Email Send to Customer'),
- 'view_type': 'form',
- 'context': cntx, # improve me
- 'view_mode': 'tree,form',
- 'res_model': 'close.task',
- 'views': [(resource_id,'form')],
- 'type': 'ir.actions.act_window',
- 'target': 'new',
- 'nodestroy': True
- }
- else:
- self.write(cr, uid, [task_id], {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
- return False
+ self.write(cr, uid, [task.id], {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
+ message = _('Task ') + " '" + task.name + "' "+ _("is Done.")
+ self.log(cr, uid, task.id, message)
+ return True
def do_reopen(self, cr, uid, ids, *args):
request = self.pool.get('res.request')
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml
index 8e1c6eba815..926355089b8 100644
--- a/addons/project/project_view.xml
+++ b/addons/project/project_view.xml
@@ -267,7 +267,7 @@
-
+
@@ -344,7 +344,7 @@
-
+
diff --git a/addons/project/wizard/__init__.py b/addons/project/wizard/__init__.py
index 618eecf4b62..3ce51a80b87 100644
--- a/addons/project/wizard/__init__.py
+++ b/addons/project/wizard/__init__.py
@@ -19,7 +19,7 @@
#
##############################################################################
-import project_close_task
+import project_task_close
import project_task_delegate
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project/wizard/project_close_task.py b/addons/project/wizard/project_close_task.py
deleted file mode 100644
index f98d8853271..00000000000
--- a/addons/project/wizard/project_close_task.py
+++ /dev/null
@@ -1,145 +0,0 @@
-# -*- 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 .
-#
-##############################################################################
-
-import time
-
-from osv import fields, osv
-from tools.translate import _
-from tools import email_send as email
-
-class project_close_task(osv.osv_memory):
- """
- Close Task
- """
- _name = "close.task"
- _description = "Project Close Task"
- _columns = {
- 'manager_email': fields.char('Manager E-Mail ID', size=64, help="Email Address of Project's Manager"),
- 'partner_email': fields.char('Partner E-Mail ID', size=64, help="Email Address of Partner"),
- 'description': fields.text('Description'),
- }
-
- def _get_manager_email(self, cr, uid, context=None):
- if context is None:
- context = {}
- email = ''
- if context.get('send_manager', False) and ('task_id' in context):
- project_id = self.pool.get('project.task').read(cr, uid, context['task_id'], ['project_id'])['project_id'][0]
- project = self.pool.get('project.project').browse(cr, uid, project_id)
- manager_id = project.user_id or False
- if manager_id and manager_id.user_email:
- email = manager_id.user_email
- return email
-
- def _get_partner_email(self, cr, uid, context=None):
- if context is None:
- context = {}
- email = ''
- if context.get('send_partner', False) and ('task_id' in context):
- task = self.pool.get('project.task').browse(cr, uid, context['task_id'])
- partner_id = task.partner_id or task.project_id.partner_id
- if partner_id and len(partner_id.address) and partner_id.address[0].email:
- email = partner_id.address[0].email
- return email
-
- def _get_desc(self, cr, uid, context=None):
- if context is None:
- context = {}
- if 'task_id' in context:
- task = self.pool.get('project.task').browse(cr, uid, context['task_id'])
- return task.description or task.name
- return ''
-
- _defaults = {
- 'manager_email': _get_manager_email,
- 'partner_email': _get_partner_email,
- }
-
- def close(self, cr, uid, ids, context=None):
- data = self.read(cr,uid,ids)[0]
- notes=data['description'] or ''
- task_pool = self.pool.get('project.task')
- user_name = self.pool.get('res.users').browse(cr, uid, uid).name
- description = _("Closed By ") + user_name + _(" At ") + time.strftime('%Y-%m-%d %H:%M:%S')
- description += "\n" + "=======================" + "\n" + notes
- if 'task_id' in context:
- task = task_pool.browse(cr, uid, context['task_id'])
- description = task.description and task.description + "\n\n" + description
- task_pool.write(cr, uid, [task.id], {
- 'description': description,
- 'state': 'done',
- 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'),
- 'remaining_hours': 0.0
- })
- return {}
-
- def confirm(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
- if not 'task_id' in context:
- return {}
- close_task = self.read(cr, uid, ids[0], [])
- to_adr = []
- description = close_task['description']
-
- if 'task_id' in context:
- if context.get('send_manager', False) and not close_task.get('manager_email', False):
- raise osv.except_osv(_('Error'), _("Please specify the email address of Project Manager."))
-
- elif context.get('send_partner', False) and not close_task.get('partner_email', False):
- raise osv.except_osv(_('Error'), _("Please specify the email address of partner."))
-
- else:
- task_obj = self.pool.get('project.task')
- task = task_obj.browse(cr, uid, context['task_id'], context=context)
- project = task.project_id
- subject = "Task '%s' closed" % task.name
- if task.user_id and task.user_id.address_id and task.user_id.address_id.email:
- from_adr = task.user_id.address_id.email
- signature = task.user_id.signature
- else:
- raise osv.except_osv(_('Error'), _("Couldn't send mail because your email address is not configured!"))
- val = {
- 'name': task.name,
- 'user_id': task.user_id.name,
- 'task_id': "%d/%d" % (project.id, task.id),
- 'date_start': task.date_start,
- 'date_end': task.date_end,
- 'state': task.state
- }
-
- header = (project.warn_header or '') % val
- footer = (project.warn_footer or '') % val
- body = u'%s\n%s\n%s\n\n-- \n%s' % (header, description, footer, signature)
- to_adr.append(context.get('send_manager', '') and close_task.get('manager_email', '') or '')
- to_adr.append(context.get('send_partner', '') and close_task.get('partner_email', '') or '')
- mail_id = email(from_adr, to_adr, subject, body.encode('utf-8'), email_bcc=[from_adr])
- if not mail_id:
- raise osv.except_osv(_('Error'), _("Couldn't send mail! Check the email ids and smtp configuration settings"))
- task_obj.write(cr, uid, [task.id], {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
- message = _('Task ') + " '" + task.name + "' "+ _("is Done.")
- self.log(cr, uid, task.id, message)
-
- return {}
-
-project_close_task()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project/wizard/project_close_task_view.xml b/addons/project/wizard/project_close_task_view.xml
deleted file mode 100644
index 6a861fcfd10..00000000000
--- a/addons/project/wizard/project_close_task_view.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
- Project Close Task
- close.task
- form
-
-
-
-
-
-
- Project Close Task
- ir.actions.act_window
- close.task
- form
- form
-
- {'record_id' : active_id}
- new
-
-
-
-
diff --git a/addons/project/wizard/project_task_close.py b/addons/project/wizard/project_task_close.py
new file mode 100644
index 00000000000..55f06f04140
--- /dev/null
+++ b/addons/project/wizard/project_task_close.py
@@ -0,0 +1,120 @@
+# -*- 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 .
+#
+##############################################################################
+
+import time
+
+from osv import fields, osv
+from tools.translate import _
+from tools import email_send as email
+
+class project_task_close(osv.osv_memory):
+ """
+ Close Task
+ """
+ _name = "project.task.close"
+ _description = "Project Close Task"
+ _columns = {
+ 'manager_warn': fields.boolean("Warn Manager", help="Warn Manager by Email"),
+ 'partner_warn': fields.boolean("Warn Customer", help="Warn Customer by Email"),
+ 'manager_email': fields.char('Manager Email', size=128, help="Email Address of Project's Manager"),
+ 'partner_email': fields.char('Customer Email', size=128, help="Email Address of Customer"),
+ 'description': fields.text('Description'),
+ }
+
+ def default_get(self, cr, uid, fields, context=None):
+ """
+ This function gets default values
+ """
+ if context is None:
+ context = {}
+ record_id = context and context.get('active_id', False) or False
+ task_pool = self.pool.get('project.task')
+ project_pool = self.pool.get('project.project')
+
+ res = super(project_task_close, self).default_get(cr, uid, fields, context=context)
+ task = task_pool.browse(cr, uid, record_id, context=context)
+ project = task.project_id
+ manager = project.user_id or False
+ partner = task.partner_id or task.project_id.partner_id
+
+ if 'description' in fields:
+ res.update({'description': task.description})
+ if 'manager_warn' in fields:
+ res.update({'manager_warn': project.warn_manager})
+ if 'partner_warn' in fields:
+ res.update({'partner_warn': project.warn_customer})
+ if 'manager_email' in fields:
+ res.update({'manager_email': manager and manager.user_email or False})
+ if partner and len(partner.address) and 'partner_email' in fields:
+ res.update({'partner_email': partner.address[0].email})
+ return res
+
+ def confirm(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
+
+ task_pool = self.pool.get('project.task')
+ task_id = context.get('active_id', False)
+ if not task_id:
+ return {}
+ task = task_pool.browse(cr, uid, task_id, context=context)
+ 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
+ if data.manager_warn and not data.manager_email:
+ raise osv.except_osv(_('Error'), _("Please specify the email address of Project Manager."))
+
+ elif data.partner_warn and not data.partner_email:
+ raise osv.except_osv(_('Error'), _("Please specify the email address of Customer."))
+
+ elif data.manager_warn or data.partner_warn:
+ project = task.project_id
+ subject = _("Task '%s' Closed") % task.name
+ if task.user_id and task.user_id.address_id and task.user_id.address_id.email:
+ from_adr = task.user_id.address_id.email
+ signature = task.user_id.signature
+ else:
+ raise osv.except_osv(_('Error'), _("Couldn't send mail because your email address is not configured!"))
+ val = {
+ 'name': task.name,
+ 'user_id': task.user_id.name,
+ 'task_id': "%d/%d" % (project.id, task.id),
+ 'date_start': task.date_start,
+ 'date_end': task.date_end,
+ 'state': task.state
+ }
+
+ header = (project.warn_header or '') % val
+ footer = (project.warn_footer or '') % val
+ body = u'%s\n%s\n%s\n\n-- \n%s' % (header, description, footer, signature)
+ if data.manager_warn and data.manager_email:
+ to_adr.append(data.manager_email)
+ if data.partner_warn and data.partner_email:
+ to_adr.append(data.partner_email)
+ mail_id = email(from_adr, to_adr, subject, tools.ustr(body), email_bcc=[from_adr])
+ if not mail_id:
+ raise osv.except_osv(_('Error'), _("Couldn't send mail! Check the email ids and smtp configuration settings"))
+ return {}
+
+project_task_close()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project/wizard/project_task_close_view.xml b/addons/project/wizard/project_task_close_view.xml
new file mode 100644
index 00000000000..c4cf72fbdd2
--- /dev/null
+++ b/addons/project/wizard/project_task_close_view.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+ Done Task
+ project.task.close
+ form
+
+
+
+
+
+
+ Done Task
+ ir.actions.act_window
+ project.task.close
+ form
+ form
+
+ new
+
+
+
+