[IMP] project, project_planning :- integreate email.compose.message wizard with proje...
authorYogesh (OpenERP) <ysa@tinyerp.com>
Tue, 22 Feb 2011 07:05:31 +0000 (12:35 +0530)
committerYogesh (OpenERP) <ysa@tinyerp.com>
Tue, 22 Feb 2011 07:05:31 +0000 (12:35 +0530)
bzr revid: ysa@tinyerp.com-20110222070531-is1ofaciyoof1qlu

addons/project/__openerp__.py
addons/project/wizard/__init__.py
addons/project/wizard/email_compose_message.py [new file with mode: 0644]
addons/project_planning/project_planning_view.xml

index 301600d..b32a9b8 100644 (file)
@@ -37,7 +37,7 @@ work done on tasks, eso. It is able to render planning, order tasks, eso.
     "update_xml": [
         "security/project_security.xml",
         "wizard/project_task_delegate_view.xml",
-        "wizard/project_task_close_view.xml",
+#        "wizard/project_task_close_view.xml",
         "wizard/project_task_reevaluate_view.xml",
         "security/ir.model.access.csv",
         "project_data.xml",
index 69e1051..5225a2d 100644 (file)
@@ -19,7 +19,8 @@
 #
 ##############################################################################
 
-import project_task_close
+#import project_task_close
+import email_compose_message
 import project_task_delegate
 import project_task_reevaluate
 
diff --git a/addons/project/wizard/email_compose_message.py b/addons/project/wizard/email_compose_message.py
new file mode 100644 (file)
index 0000000..042cdd6
--- /dev/null
@@ -0,0 +1,81 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>)
+#
+#    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 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 General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+from tools.translate import _
+
+class email_compose_message(osv.osv_memory):
+    _inherit = 'email.compose.message'
+
+    def default_get(self, cr, uid, fields, context=None):
+        if context is None:
+            context = {}
+        result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
+        if context.get('active_id',False) and context.get('active_model',False) and context.get('active_model') == 'project.task':
+            task_pool = self.pool.get('project.task')
+            task_data = task_pool.browse(cr, uid, context.get('active_id'), context=context)
+            project = task_data.project_id
+            manager = project.user_id or False
+            partner = task_data.partner_id or task_data.project_id.partner_id
+
+            if project.warn_manager and (not manager or manager and not manager.user_email) :
+                raise osv.except_osv(_('Error'), _("Please specify the Project Manager or email address of Project Manager."))
+            elif project.warn_customer and (not partner or not len(partner.address) or (partner and len(partner.address) and not partner.address[0].email)):
+                raise osv.except_osv(_('Error'), _("Please specify the Customer or email address of Customer."))
+
+            if 'email_from' in fields:
+                result.update({'email_from': task_data.user_id and task_data.user_id.user_email or False})
+
+            if 'description' in fields:
+                val = {
+                        'name': task_data.name,
+                        'user_id': task_data.user_id.name,
+                        'task_id': "%d/%d" % (project.id, task_data.id),
+                        'date_start': task_data.date_start,
+                        'date': task_data.date_end,
+                        'state': task_data.state
+                }
+                header = (project.warn_header or '') % val
+                footer = (project.warn_footer or '') % val
+                description = u'%s\n %s\n %s\n\n \n%s' % (header, task_data.description or '', footer, task_data.user_id and task_data.user_id.signature)
+                result.update({'description': description or False})
+
+            if 'email_to' in fields:
+                result.update({'email_to':   manager and manager.user_email or False})
+
+            if partner and len(partner.address) and 'email_to' in fields:
+                result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email})
+
+            if 'name' in fields:
+                result.update({'name':  _("Task '%s' Closed") % task_data.name})
+
+            if 'model' in fields:
+                result.update({'model':context.get('active_model')})
+
+            if 'res_id' in fields:
+                result.update({'res_id':context.get('active_id')})
+
+        return result
+
+email_compose_message()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index ef39b5d..11ced59 100644 (file)
                                                         <button name="do_reopen" states="done,cancelled" string="Reactivate" type="object" icon="gtk-convert"/>
                                                         <button name="do_pending" states="open" string="Pending" type="object" icon="gtk-media-pause"/>
                                                         <button groups="base.group_extended" name="%(project.action_project_task_delegate)d" states="pending,open" string="Delegate" type="action" icon="gtk-sort-descending"/>
-                                                        <button name="%(project.action_project_task_close)d" states="pending,open" string="Done" type="action" icon="gtk-jump-to"/>
+                                                        <button name="%(emails.action_email_compose_message_wizard)d" context="{'mail':'new'}" states="pending,open" string="Done" type="action" icon="gtk-jump-to"/>
                                                     </group>
                                                  </page>
                                                 <page groups="base.group_extended" string="Extra Info" attrs="{'readonly':[('state','=','done')]}">