diff options
| author | Stephane Wirtel <stw@openerp.com> | 2011-09-13 16:00:16 +0200 |
|---|---|---|
| committer | Stephane Wirtel <stw@openerp.com> | 2011-09-13 16:00:16 +0200 |
| commit | 2a59ce92e3ea35cca00a314d44556b522b3c2fa8 (patch) | |
| tree | 6e7eec2157a513284e6740a95f2e39b7f04aef79 /addons/hr_evaluation/wizard | |
| parent | 8a2bc42c3c45b4d3c94070a29fa76636256f3da7 (diff) | |
| parent | 2a40f9a4997eecc6f997ab0e43dc6334263b9cad (diff) | |
[MERGE] Email Framework - lp:~openerp-dev/openobject-addons/trunk-emails-unified
bzr revid: stw@openerp.com-20110913140016-zzfynrnjdaap0tfb
Diffstat (limited to 'addons/hr_evaluation/wizard')
| -rw-r--r-- | addons/hr_evaluation/wizard/__init__.py | 3 | ||||
| -rw-r--r-- | addons/hr_evaluation/wizard/hr_evaluation_mail.py | 9 | ||||
| -rw-r--r-- | addons/hr_evaluation/wizard/mail_compose_message.py | 60 |
3 files changed, 66 insertions, 6 deletions
diff --git a/addons/hr_evaluation/wizard/__init__.py b/addons/hr_evaluation/wizard/__init__.py index 1a855087bbc..64406ac6b1e 100644 --- a/addons/hr_evaluation/wizard/__init__.py +++ b/addons/hr_evaluation/wizard/__init__.py @@ -19,6 +19,7 @@ # ############################################################################## -import hr_evaluation_mail +#import hr_evaluation_mail +import mail_compose_message # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_evaluation/wizard/hr_evaluation_mail.py b/addons/hr_evaluation/wizard/hr_evaluation_mail.py index 17ad7415cb5..35c54a4cca3 100644 --- a/addons/hr_evaluation/wizard/hr_evaluation_mail.py +++ b/addons/hr_evaluation/wizard/hr_evaluation_mail.py @@ -23,21 +23,20 @@ import tools class hr_evaluation_reminder(osv.osv_memory): _name = "hr.evaluation.reminder" - _description = "Sends Reminders to employess to fill the evaluations" + _description = "Sends Reminders to employees to fill the evaluations" _columns = { 'evaluation_id': fields.many2one('hr.evaluation.interview', 'Interview', required=True) } def send_mail(self, cr, uid, ids, context=None): + mail_message = self.pool.get('mail.message') hr_evaluation_interview_obj = self.pool.get('hr.evaluation.interview') evaluation_data = self.read(cr, uid, ids, context=context)[0] current_interview = hr_evaluation_interview_obj.browse(cr, uid, evaluation_data.get('evaluation_id')) if current_interview.state == "waiting_answer" and current_interview.user_to_review_id.work_email : msg = " Hello %s, \n\n Kindly post your response for '%s' survey interview. \n\n Thanks," %(current_interview.user_to_review_id.name, current_interview.survey_id.title) - tools.email_send(tools.config['email_from'], [current_interview.user_to_review_id.work_email],\ - 'Reminder to fill up Survey', msg) + mail_message.schedule_with_attach(cr, uid, tools.config['email_from'], [current_interview.user_to_review_id.work_email],\ + 'Reminder to fill up Survey', msg, context=context) return {'type': 'ir.actions.act_window_close'} -hr_evaluation_reminder() - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_evaluation/wizard/mail_compose_message.py b/addons/hr_evaluation/wizard/mail_compose_message.py new file mode 100644 index 00000000000..7b4c1b69164 --- /dev/null +++ b/addons/hr_evaluation/wizard/mail_compose_message.py @@ -0,0 +1,60 @@ +# -*- 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 +import tools +from tools.translate import _ + +class mail_compose_message(osv.osv_memory): + _inherit = 'mail.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(mail_compose_message, self).get_value(cr, uid, model, resource_id, context=context) + if model == 'hr.evaluation.interview' and resource_id: + model_pool = self.pool.get(model) + record_data = model_pool.browse(cr, uid, resource_id, context) + if record_data.state == "waiting_answer": + msg = _("Hello %s, \n\n Kindly post your response for '%s' survey interview. \n\n Thanks,") %(record_data.user_to_review_id.name, record_data.survey_id.title) + result.update({ + 'email_from': tools.config.get('email_from',''), + 'email_to': record_data.user_to_review_id.work_email or False, + 'subject': _("Reminder to fill up Survey"), + 'body_text': msg, + 'res_id': resource_id, + 'model': model, + 'email_cc': False, + 'email_bcc': False, + 'reply_to': False, + }) + return result + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
