diff --git a/addons/project/__terp__.py b/addons/project/__terp__.py
index 2af0ba122bf..65e3c58fb5e 100644
--- a/addons/project/__terp__.py
+++ b/addons/project/__terp__.py
@@ -40,7 +40,8 @@ works done on tasks, eso. It is able to render planning, order tasks, eso.
"project_report.xml",
"process/task_process.xml",
"project_installer.xml",
- "report/project_report_view.xml"
+ "report/project_report_view.xml",
+ "wizard/project_close_task_view.xml",
],
'demo_xml': [
'project_demo.xml'
diff --git a/addons/project/project.py b/addons/project/project.py
index 0c6cc839f6d..278646e097a 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -358,6 +358,8 @@ class task(osv.osv):
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)
for task in tasks:
@@ -373,6 +375,9 @@ class task(osv.osv):
'ref_doc1': 'project.task,%d'% (task.id,),
'ref_doc2': 'project.project,%d'% (project.id,),
})
+ elif project.warn_manager:
+ task_id = ids[0]
+ mail_send = True
self.write(cr, uid, [task.id], {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
for parent_id in task.parent_ids:
if parent_id.state in ('pending','draft'):
@@ -382,6 +387,20 @@ 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']
+ return {
+ 'name': _('Email Send to Customer'),
+ 'view_type': 'form',
+ 'context': {'task_id': task_id,}, # improve me
+ 'view_mode': 'tree,form',
+ 'res_model': 'close.task',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'nodestroy': True
+ }
return True
def do_reopen(self, cr, uid, ids, *args):
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml
index b910515c950..47cdefe3cee 100644
--- a/addons/project/project_view.xml
+++ b/addons/project/project_view.xml
@@ -271,7 +271,8 @@
-
+
+
@@ -350,7 +351,8 @@
-
+
+
diff --git a/addons/project/project_wizard.xml b/addons/project/project_wizard.xml
index e2b7442f26e..0e9a5c8b3c1 100644
--- a/addons/project/project_wizard.xml
+++ b/addons/project/project_wizard.xml
@@ -1,7 +1,7 @@
-
+
).
-#
-# 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 wizard
-from tools import email_send as email
-import pooler
-from osv import osv
-from tools.translate import _
-
-mail_form = """
-"""
-
-mail_fields = {
- 'email': {'string': 'E-Mails', 'type': 'char', 'required': 'True', 'size':64},
- 'description': {'string':'Description', 'type':'text', 'required':'True'},
-}
-
-def email_send(cr, uid, ids, to_adr, description, context={}):
- pool = pooler.get_pool(cr.dbname)
- for task in pool.get('project.task').browse(cr, uid, ids, 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 wizard.except_wizard(_('Error'), _("Couldn't send mail because your email address is not configured!"))
- if to_adr:
- val = {
- 'name': task.name,
- 'user_id': task.user_id.name,
- 'task_id': "%d/%d" % (project.id, task.id),
- 'date_start': task.date_start,
- 'date_close': task.date_close,
- '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)
- email(from_adr, [to_adr], subject, body.encode('utf-8'), email_bcc=[from_adr])
- else:
- raise wizard.except_wizard(_('Error'), _("Couldn't send mail because the contact for this task (%s) has no email address!") % contact.name)
-
-class wizard_close(wizard.interface):
- def _check_complete(self, cr, uid, data, context):
- task = pooler.get_pool(cr.dbname).get('project.task').browse(cr, uid, data['ids'])[0]
- if not (task.project_id and task.project_id.warn_customer):
- return 'close'
- return 'mail_ask'
-
- def _get_data(self, cr, uid, data, context):
- email = ''
- task = pooler.get_pool(cr.dbname).get('project.task').browse(cr, uid, data['ids'][0])
- partner_id = task.partner_id or task.project_id.partner_id
- if partner_id and partner_id.address[0].email:
- email = partner_id.address[0].email
- return {'description': task.description or task.name, 'email':email}
-
- def _data_send(self, cr, uid, data, context):
- task_obj = pooler.get_pool(cr.dbname).get('project.task')
- if data['form']['email']:
- description = data['form'].get('description', False)
- email_send(cr, uid, data['ids'], data['form']['email'], data['form']['description'])
- return {}
-
- def _do_close(self, cr, uid, data, context):
- task_obj = pooler.get_pool(cr.dbname).get('project.task')
- task_obj.do_close(cr, uid, data['ids'], context)
- return {}
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type':'choice', 'next_state':_check_complete}
- },
- 'mail_ask': {
- 'actions': [_get_data],
- 'result': {'type':'form', 'arch':mail_form, 'fields':mail_fields, 'state':[('end', 'Cancel'), ('close', 'Quiet close'), ('mail_send', 'Send Message')]},
- },
- 'mail_send': {
- 'actions': [_data_send],
- 'result': {'type':'state', 'state':'close'},
- },
- 'close': {
- 'actions': [_do_close],
- 'result': {'type':'state', 'state':'end'},
- },
- }
-wizard_close('project.task.close')
-
-
-# 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
new file mode 100644
index 00000000000..947806224f4
--- /dev/null
+++ b/addons/project/wizard/project_close_task.py
@@ -0,0 +1,87 @@
+# -*- 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 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 = {
+ 'email': fields.char('E-Mails', size=64,),
+ 'description': fields.text('Description',),
+ }
+
+ def _get_email(self, cr, uid, context={}):
+ email = ''
+ task = self.pool.get('project.task').browse(cr, uid, context['active_ids'][0])
+ partner_id = task.partner_id or task.project_id.partner_id
+ if partner_id and partner_id.address[0].email:
+ email = partner_id.address[0].email
+ return email
+
+ def _get_desc(self, cr, uid, context={}):
+ task = self.pool.get('project.task').browse(cr, uid, context['active_ids'][0])
+ return task.description or task.name
+
+ _defaults={
+ 'email': _get_email,
+ 'description': _get_desc,
+ }
+
+ def confirm(self, cr, uid, ids, context={}):
+ if not 'task_id' in context:
+ return {}
+ close_task = self.read(cr, uid, ids[0], [])
+ to_adr = close_task['email']
+ description = close_task['description']
+ for task in self.pool.get('project.task').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!"))
+ if to_adr:
+ 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)
+ email(from_adr, [to_adr], subject, body.encode('utf-8'), email_bcc=[from_adr])
+ else:
+ raise osv.except_osv(_('Error'), _("Couldn't send mail because the contact for this task (%s) has no email address!") % contact.name)
+ return {}
+
+project_close_task()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/project/wizard/project_close_task_view.xml b/addons/project/wizard/project_close_task_view.xml
new file mode 100644
index 00000000000..534312d7629
--- /dev/null
+++ b/addons/project/wizard/project_close_task_view.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+ Project Close Task
+ close.task
+ form
+
+
+
+
+
+
+ Project Close Task
+ ir.actions.act_window
+ close.task
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
\ No newline at end of file