From fd88efc23ba5109835ee215284327a6b93758219 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 22 Feb 2011 12:35:31 +0530 Subject: [PATCH] [IMP] project, project_planning :- integreate email.compose.message wizard with project.close.task in project module. bzr revid: ysa@tinyerp.com-20110222070531-is1ofaciyoof1qlu --- addons/project/__openerp__.py | 2 +- addons/project/wizard/__init__.py | 3 +- addons/project/wizard/email_compose_message.py | 81 +++++++++++++++++++++ addons/project_planning/project_planning_view.xml | 2 +- 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 addons/project/wizard/email_compose_message.py diff --git a/addons/project/__openerp__.py b/addons/project/__openerp__.py index 301600d..b32a9b8 100644 --- a/addons/project/__openerp__.py +++ b/addons/project/__openerp__.py @@ -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", diff --git a/addons/project/wizard/__init__.py b/addons/project/wizard/__init__.py index 69e1051..5225a2d 100644 --- a/addons/project/wizard/__init__.py +++ b/addons/project/wizard/__init__.py @@ -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 index 0000000..042cdd6 --- /dev/null +++ b/addons/project/wizard/email_compose_message.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-Today OpenERP SA () +# +# 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 +# +############################################################################## + +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: diff --git a/addons/project_planning/project_planning_view.xml b/addons/project_planning/project_planning_view.xml index ef39b5d..11ced59 100644 --- a/addons/project_planning/project_planning_view.xml +++ b/addons/project_planning/project_planning_view.xml @@ -109,7 +109,7 @@