From bbdac458fdbd5ece78fc674767177f91b045e4bc Mon Sep 17 00:00:00 2001 From: "YSA (Openerp)" Date: Fri, 4 Feb 2011 11:48:19 +0530 Subject: [IMP] call email_send method of email.message object insted of tools. bzr revid: ysa@tinyerp.com-20110204061819-bb3p94bs7og680je --- addons/project/wizard/project_task_close.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'addons/project/wizard') diff --git a/addons/project/wizard/project_task_close.py b/addons/project/wizard/project_task_close.py index 7091f466e2c..5f0bad6f4da 100644 --- a/addons/project/wizard/project_task_close.py +++ b/addons/project/wizard/project_task_close.py @@ -45,13 +45,13 @@ class project_task_close(osv.osv_memory): context = {} record_id = context and context.get('active_id', False) or False task_pool = self.pool.get('project.task') - + 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 or False}) if 'manager_warn' in fields: @@ -67,7 +67,8 @@ class project_task_close(osv.osv_memory): def send(self, cr, uid, ids, context=None): if context is None: context = {} - + + email_message_obj = self.pool.get('email.message') task_pool = self.pool.get('project.task') task_id = context.get('active_id', False) if not task_id: @@ -106,7 +107,7 @@ class project_task_close(osv.osv_memory): to_adr.append(data.manager_email) if data.partner_warn and data.partner_email: to_adr.append(data.partner_email) - mail_id = tools.email_send(from_adr, to_adr, subject, tools.ustr(body), email_bcc=[from_adr]) + mail_id = email_message_obj.email_send(from_adr, to_adr, subject, tools.ustr(body), model='project.task.close', 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 {} -- cgit v1.2.3 From 659900e4d5c256dedf78c13d227d9afab379499e Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Wed, 9 Feb 2011 14:48:48 +0530 Subject: [IMP] add argument in email_send method of addons module. bzr revid: ysa@tinyerp.com-20110209091848-tb1d9qcj9bz3iq2b --- addons/project/wizard/project_task_close.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/project/wizard') diff --git a/addons/project/wizard/project_task_close.py b/addons/project/wizard/project_task_close.py index 5f0bad6f4da..0657888ccb4 100644 --- a/addons/project/wizard/project_task_close.py +++ b/addons/project/wizard/project_task_close.py @@ -107,7 +107,7 @@ class project_task_close(osv.osv_memory): to_adr.append(data.manager_email) if data.partner_warn and data.partner_email: to_adr.append(data.partner_email) - mail_id = email_message_obj.email_send(from_adr, to_adr, subject, tools.ustr(body), model='project.task.close', email_bcc=[from_adr]) + mail_id = email_message_obj.email_send(cr, uid, from_adr, to_adr, subject, tools.ustr(body), model='project.task.close', 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 {} -- cgit v1.2.3 From fd88efc23ba5109835ee215284327a6b93758219 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 22 Feb 2011 12:35:31 +0530 Subject: [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/wizard/__init__.py | 3 +- addons/project/wizard/email_compose_message.py | 81 ++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 addons/project/wizard/email_compose_message.py (limited to 'addons/project/wizard') diff --git a/addons/project/wizard/__init__.py b/addons/project/wizard/__init__.py index 69e1051e621..5225a2d661e 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 00000000000..042cdd61a30 --- /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: -- cgit v1.2.3 From d5494f5ea4a7b50277a040ee22a8bab6741f00af Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 28 Feb 2011 17:09:19 +0530 Subject: [IMP] emails,crm,project,project_scrum :- improve email.compose.wizard and add blank value add in selection box of template_id field in wizard. if template_id blank then default value set based on current record. bzr revid: ysa@tinyerp.com-20110228113919-d7quaz8uqmjnkuzh --- addons/project/wizard/email_compose_message.py | 85 ++++++++++++++++++-------- 1 file changed, 60 insertions(+), 25 deletions(-) (limited to 'addons/project/wizard') diff --git a/addons/project/wizard/email_compose_message.py b/addons/project/wizard/email_compose_message.py index 042cdd61a30..59b7258eb9d 100644 --- a/addons/project/wizard/email_compose_message.py +++ b/addons/project/wizard/email_compose_message.py @@ -26,56 +26,91 @@ from tools.translate import _ class email_compose_message(osv.osv_memory): _inherit = 'email.compose.message' + def get_value(self, cr, uid, model, resource_id, context=None): + if context is None: + context = {} + result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context) + if model != 'project.task': + return result + task_pool = self.pool.get('project.task') + task_data = task_pool.browse(cr, uid, resource_id, context=context) + partner = task_data.partner_id or task_data.project_id.partner_id + + result.update({'email_from': task_data.user_id and task_data.user_id.user_email or False}) + val = { + 'name': task_data.name, + 'user_id': task_data.user_id.name, + 'task_id': "%d/%d" % (task_data.project_id.id, task_data.id), + 'date_start': task_data.date_start, + 'date': task_data.date_end, + 'state': task_data.state + } + header = (task_data.project_id.warn_header or '') % val + footer = (task_data.project_id.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}) + result.update({'email_to': task_data.project_id.user_id and task_data.project_id.user_id.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}) + result.update({'name': _("Task '%s' Closed") % task_data.name}) + + return result + 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': + if context.get('active_id',False) and context.get('email_model',False) and context.get('email_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) : + if task_data.project_id.warn_manager and (not task_data.project_id.user_id or task_data.project_id.user_id and not task_data.project_id.user_id.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)): + elif task_data.project_id.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.")) - + vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context) if 'email_from' in fields: - result.update({'email_from': task_data.user_id and task_data.user_id.user_email or False}) + result.update({'email_from': vals.get('email_from','')}) 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}) + result.update({'description': vals.get('description','')}) 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}) + result.update({'description': vals.get('description','')}) if 'name' in fields: - result.update({'name': _("Task '%s' Closed") % task_data.name}) + result.update({'description': vals.get('name','')}) if 'model' in fields: - result.update({'model':context.get('active_model')}) + result.update({'model':context.get('email_model')}) if 'res_id' in fields: result.update({'res_id':context.get('active_id')}) return result + def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None): + if context is None: + context = {} + if context.get('mail') == 'reply': + return {'value':{}} + result = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context) + if not result.get('value'): + result.update({'value':{}}) + if resource_id and model == 'project.task': + vals = self.get_value(cr, uid, model, resource_id, context) + result.get('value',{}).update({ + 'email_from': vals.get('email_from',''), + 'email_to': vals.get('email_to',''), + 'description': vals.get('description',''), + 'name': vals.get('name',''), + 'email_cc': vals.get('email_cc',''), + 'email_bcc': vals.get('email_bcc',''), + 'reply_to': vals.get('reply_to',''), + }) + return result + email_compose_message() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From 67e07f8bd3847b1948e254f03c155ec15c6054d5 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 1 Mar 2011 12:27:48 +0530 Subject: [IMP] email.compose.message wizard:- improve code. bzr revid: ysa@tinyerp.com-20110301065748-2mc5hygt3gcd0p70 --- addons/project/wizard/email_compose_message.py | 94 +++++++------------------- 1 file changed, 23 insertions(+), 71 deletions(-) (limited to 'addons/project/wizard') diff --git a/addons/project/wizard/email_compose_message.py b/addons/project/wizard/email_compose_message.py index 59b7258eb9d..2796dc602c1 100644 --- a/addons/project/wizard/email_compose_message.py +++ b/addons/project/wizard/email_compose_message.py @@ -30,85 +30,37 @@ class email_compose_message(osv.osv_memory): if context is None: context = {} result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context) - if model != 'project.task': - return result - task_pool = self.pool.get('project.task') - task_data = task_pool.browse(cr, uid, resource_id, context=context) - partner = task_data.partner_id or task_data.project_id.partner_id - - result.update({'email_from': task_data.user_id and task_data.user_id.user_email or False}) - val = { - 'name': task_data.name, - 'user_id': task_data.user_id.name, - 'task_id': "%d/%d" % (task_data.project_id.id, task_data.id), - 'date_start': task_data.date_start, - 'date': task_data.date_end, - 'state': task_data.state - } - header = (task_data.project_id.warn_header or '') % val - footer = (task_data.project_id.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}) - result.update({'email_to': task_data.project_id.user_id and task_data.project_id.user_id.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}) - result.update({'name': _("Task '%s' Closed") % task_data.name}) - - return result - - 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('email_model',False) and context.get('email_model') == 'project.task': + if model == 'project.task' and resource_id: task_pool = self.pool.get('project.task') - task_data = task_pool.browse(cr, uid, context.get('active_id'), context=context) + task_data = task_pool.browse(cr, uid, resource_id, context=context) partner = task_data.partner_id or task_data.project_id.partner_id - if task_data.project_id.warn_manager and (not task_data.project_id.user_id or task_data.project_id.user_id and not task_data.project_id.user_id.user_email) : raise osv.except_osv(_('Error'), _("Please specify the Project Manager or email address of Project Manager.")) elif task_data.project_id.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.")) - vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context) - if 'email_from' in fields: - result.update({'email_from': vals.get('email_from','')}) - - if 'description' in fields: - result.update({'description': vals.get('description','')}) - - if 'email_to' in fields: - result.update({'description': vals.get('description','')}) - if 'name' in fields: - result.update({'description': vals.get('name','')}) - - if 'model' in fields: - result.update({'model':context.get('email_model')}) - - if 'res_id' in fields: - result.update({'res_id':context.get('active_id')}) - - return result - - def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None): - if context is None: - context = {} - if context.get('mail') == 'reply': - return {'value':{}} - result = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context) - if not result.get('value'): - result.update({'value':{}}) - if resource_id and model == 'project.task': - vals = self.get_value(cr, uid, model, resource_id, context) - result.get('value',{}).update({ - 'email_from': vals.get('email_from',''), - 'email_to': vals.get('email_to',''), - 'description': vals.get('description',''), - 'name': vals.get('name',''), - 'email_cc': vals.get('email_cc',''), - 'email_bcc': vals.get('email_bcc',''), - 'reply_to': vals.get('reply_to',''), + result.update({'email_from': task_data.user_id and task_data.user_id.user_email or False}) + val = { + 'name': task_data.name, + 'user_id': task_data.user_id.name, + 'task_id': "%d/%d" % (task_data.project_id.id, task_data.id), + 'date_start': task_data.date_start, + 'date': task_data.date_end, + 'state': task_data.state + } + header = (task_data.project_id.warn_header or '') % val + footer = (task_data.project_id.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) + 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}) + result.update({ + 'description': description or False, + 'email_to': task_data.project_id.user_id and task_data.project_id.user_id.user_email or False, + 'name': _("Task '%s' Closed") % task_data.name, + 'model': model, + 'res_id': resource_id, }) + return result email_compose_message() -- cgit v1.2.3 From 2fe7c51e361ade79eef9af67f11a96a5fc24b035 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Mon, 21 Mar 2011 19:01:56 +0530 Subject: [REM] email.smtp_server: removed email.smtp_server and did changes in email module bzr revid: rha@tinyerp.com-20110321133156-y57yw6sekshnw9ns --- addons/project/wizard/project_task_close.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/project/wizard') diff --git a/addons/project/wizard/project_task_close.py b/addons/project/wizard/project_task_close.py index f396dcecca7..b4b4f46c9a5 100644 --- a/addons/project/wizard/project_task_close.py +++ b/addons/project/wizard/project_task_close.py @@ -113,7 +113,7 @@ class project_task_close(osv.osv_memory): to_adr.append(data.manager_email) if data.partner_warn and data.partner_email: to_adr.append(data.partner_email) - mail_id = email_message_obj.email_send(cr, uid, from_adr, to_adr, subject, tools.ustr(body), model='project.task.close', email_bcc=[from_adr]) + mail_id = email_message_obj.schedule_with_attach(cr, uid, from_adr, to_adr, subject, tools.ustr(body), model='project.task.close', 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 {} -- cgit v1.2.3 From f53ee6053a0e4f2ed8abbeee6469edf634de3d64 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Thu, 7 Apr 2011 18:20:24 +0530 Subject: [IMP] email.message.common: implemented active_id and active_model in default_get() and fix reference of fields subject and body bzr revid: rha@tinyerp.com-20110407125024-4354406jcb4ih2k9 --- addons/project/wizard/email_compose_message.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/project/wizard') diff --git a/addons/project/wizard/email_compose_message.py b/addons/project/wizard/email_compose_message.py index 68445661716..eb52604749e 100644 --- a/addons/project/wizard/email_compose_message.py +++ b/addons/project/wizard/email_compose_message.py @@ -54,9 +54,9 @@ class email_compose_message(osv.osv_memory): if partner and len(partner.address): result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email}) result.update({ - 'description': description or False, + 'body': description or False, 'email_to': task_data.project_id.user_id and task_data.project_id.user_id.user_email or False, - 'name': _("Task '%s' Closed") % task_data.name, + 'subject': _("Task '%s' Closed") % task_data.name, 'model': model, 'res_id': resource_id, }) -- cgit v1.2.3 From 44bcca9f2f68f460438f1210002f52297c2bb001 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Tue, 19 Apr 2011 17:28:50 +0530 Subject: [IMP] email.compose.message: useability improvements bzr revid: rha@tinyerp.com-20110419115850-8vsbd9yv3vhedgss --- addons/project/wizard/email_compose_message.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'addons/project/wizard') diff --git a/addons/project/wizard/email_compose_message.py b/addons/project/wizard/email_compose_message.py index eb52604749e..921cbf1b081 100644 --- a/addons/project/wizard/email_compose_message.py +++ b/addons/project/wizard/email_compose_message.py @@ -27,6 +27,13 @@ class email_compose_message(osv.osv_memory): _inherit = 'email.compose.message' def get_value(self, cr, uid, model, resource_id, context=None): + ''' + To get values of the resource_id for the model + @param model: Object + @param resource_id: id of a record for which values to be read + + @return: Returns a dictionary + ''' if context is None: context = {} result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context) -- cgit v1.2.3 From 8f9f45ea948d1ffecb79601e860d522fc6686c2d Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 22 Aug 2011 19:16:59 +0200 Subject: [IMP] all: next pass of review/renaming for new mail API bzr revid: odo@openerp.com-20110822171659-zxho36a6n628i10q --- addons/project/wizard/email_compose_message.py | 7 ++----- addons/project/wizard/project_task_close.py | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'addons/project/wizard') diff --git a/addons/project/wizard/email_compose_message.py b/addons/project/wizard/email_compose_message.py index 921cbf1b081..2eee75c22b1 100644 --- a/addons/project/wizard/email_compose_message.py +++ b/addons/project/wizard/email_compose_message.py @@ -24,7 +24,7 @@ from osv import fields from tools.translate import _ class email_compose_message(osv.osv_memory): - _inherit = 'email.compose.message' + _inherit = 'mail.compose.message' def get_value(self, cr, uid, model, resource_id, context=None): ''' @@ -34,8 +34,6 @@ class email_compose_message(osv.osv_memory): @return: Returns a dictionary ''' - if context is None: - context = {} result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context) if model == 'project.task' and resource_id: task_pool = self.pool.get('project.task') @@ -61,7 +59,7 @@ class email_compose_message(osv.osv_memory): if partner and len(partner.address): result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email}) result.update({ - 'body': description or False, + 'body_text': description or False, 'email_to': task_data.project_id.user_id and task_data.project_id.user_id.user_email or False, 'subject': _("Task '%s' Closed") % task_data.name, 'model': model, @@ -70,6 +68,5 @@ class email_compose_message(osv.osv_memory): return result -email_compose_message() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project/wizard/project_task_close.py b/addons/project/wizard/project_task_close.py index a0710d288b3..fddc8e46f2f 100644 --- a/addons/project/wizard/project_task_close.py +++ b/addons/project/wizard/project_task_close.py @@ -68,7 +68,7 @@ class project_task_close(osv.osv_memory): if context is None: context = {} - email_message_obj = self.pool.get('email.message') + mail_message = self.pool.get('mail.message') task_pool = self.pool.get('project.task') task_id = context.get('active_id', False) if not task_id: @@ -113,7 +113,7 @@ class project_task_close(osv.osv_memory): to_adr.append(data.manager_email) if data.partner_warn and data.partner_email: to_adr.append(data.partner_email) - mail_id = email_message_obj.schedule_with_attach(cr, uid, from_adr, to_adr, subject, tools.ustr(body), model='project.task.close', email_bcc=[from_adr]) + mail_id = mail_message.schedule_with_attach(cr, uid, from_adr, to_adr, subject, tools.ustr(body), email_bcc=[from_adr], context=context) if not mail_id: raise osv.except_osv(_('Error'), _("Couldn't send mail! Check the email ids and smtp configuration settings")) return {'type': 'ir.actions.act_window_close'} -- cgit v1.2.3 From 02b83e1040d5001872ffe829e2084a124131a00c Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 8 Sep 2011 00:48:29 +0200 Subject: [IMP] project: finish cleanup/integration of mail.compose.message wizard as task close wizard bzr revid: odo@openerp.com-20110907224829-zd00lqshrfphpi31 --- addons/project/wizard/__init__.py | 1 - addons/project/wizard/project_task_close.py | 123 ---------------------- addons/project/wizard/project_task_close_view.xml | 41 -------- 3 files changed, 165 deletions(-) delete mode 100644 addons/project/wizard/project_task_close.py delete mode 100644 addons/project/wizard/project_task_close_view.xml (limited to 'addons/project/wizard') diff --git a/addons/project/wizard/__init__.py b/addons/project/wizard/__init__.py index 5225a2d661e..832130bd808 100644 --- a/addons/project/wizard/__init__.py +++ b/addons/project/wizard/__init__.py @@ -19,7 +19,6 @@ # ############################################################################## -#import project_task_close import email_compose_message import project_task_delegate import project_task_reevaluate diff --git a/addons/project/wizard/project_task_close.py b/addons/project/wizard/project_task_close.py deleted file mode 100644 index fddc8e46f2f..00000000000 --- a/addons/project/wizard/project_task_close.py +++ /dev/null @@ -1,123 +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 . -# -############################################################################## - -from osv import fields, osv -import tools -from tools.translate import _ -import re -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') - - 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 or False}) - if 'manager_warn' in fields: - res.update({'manager_warn': project.warn_manager or False}) - if 'partner_warn' in fields: - res.update({'partner_warn': project.warn_customer or False}) - 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 send(self, cr, uid, ids, context=None): - if context is None: - context = {} - - mail_message = self.pool.get('mail.message') - 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): - # Send Warn Message 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.user_email: - from_adr = task.user_id.user_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 - } - - to_adr = [] - 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, data.description or '', 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 = mail_message.schedule_with_attach(cr, uid, from_adr, to_adr, subject, tools.ustr(body), email_bcc=[from_adr], context=context) - if not mail_id: - raise osv.except_osv(_('Error'), _("Couldn't send mail! Check the email ids and smtp configuration settings")) - return {'type': 'ir.actions.act_window_close'} - -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 deleted file mode 100644 index d6bed92824d..00000000000 --- a/addons/project/wizard/project_task_close_view.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - Send Email - project.task.close - form - -
- - - - - - - - - - - - -