summaryrefslogtreecommitdiff
path: root/addons/hr_evaluation
diff options
context:
space:
mode:
authorStephane Wirtel <stw@openerp.com>2011-09-13 16:00:16 +0200
committerStephane Wirtel <stw@openerp.com>2011-09-13 16:00:16 +0200
commit2a59ce92e3ea35cca00a314d44556b522b3c2fa8 (patch)
tree6e7eec2157a513284e6740a95f2e39b7f04aef79 /addons/hr_evaluation
parent8a2bc42c3c45b4d3c94070a29fa76636256f3da7 (diff)
parent2a40f9a4997eecc6f997ab0e43dc6334263b9cad (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')
-rw-r--r--addons/hr_evaluation/__openerp__.py2
-rw-r--r--addons/hr_evaluation/hr_evaluation.py4
-rw-r--r--addons/hr_evaluation/hr_evaluation_view.xml17
-rw-r--r--addons/hr_evaluation/wizard/__init__.py3
-rw-r--r--addons/hr_evaluation/wizard/hr_evaluation_mail.py9
-rw-r--r--addons/hr_evaluation/wizard/mail_compose_message.py60
6 files changed, 84 insertions, 11 deletions
diff --git a/addons/hr_evaluation/__openerp__.py b/addons/hr_evaluation/__openerp__.py
index d2e0702f067..adf1d9d69c4 100644
--- a/addons/hr_evaluation/__openerp__.py
+++ b/addons/hr_evaluation/__openerp__.py
@@ -43,7 +43,7 @@ in the form of pdf file. Implements a dashboard for My Current Evaluations
"data": [
"security/ir.model.access.csv",
"security/hr_evaluation_security.xml",
- "wizard/hr_evaluation_mail_view.xml",
+# "wizard/hr_evaluation_mail_view.xml",
"hr_evaluation_view.xml",
"report/hr_evaluation_report_view.xml",
"board_hr_evaluation_view.xml",
diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py
index 0b0ebb92261..7634052704c 100644
--- a/addons/hr_evaluation/hr_evaluation.py
+++ b/addons/hr_evaluation/hr_evaluation.py
@@ -24,7 +24,6 @@ from datetime import datetime
from dateutil.relativedelta import relativedelta
from dateutil import parser
from osv import fields, osv
-import tools
from tools.translate import _
class hr_evaluation_plan(osv.osv):
@@ -193,6 +192,7 @@ class hr_evaluation(osv.osv):
return {'value': {'plan_id':evaluation_plan_id}}
def button_plan_in_progress(self, cr, uid, ids, context=None):
+ mail_message = self.pool.get('mail.message')
hr_eval_inter_obj = self.pool.get('hr.evaluation.interview')
if context is None:
context = {}
@@ -229,7 +229,7 @@ class hr_evaluation(osv.osv):
sub = phase.email_subject
dest = [child.work_email]
if dest:
- tools.email_send(evaluation.employee_id.work_email, dest, sub, body)
+ mail_message.schedule_with_attach(cr, uid, evaluation.employee_id.work_email, dest, sub, body, context=context)
self.write(cr, uid, ids, {'state':'wait'}, context=context)
return True
diff --git a/addons/hr_evaluation/hr_evaluation_view.xml b/addons/hr_evaluation/hr_evaluation_view.xml
index 84d2569320c..869d1f93994 100644
--- a/addons/hr_evaluation/hr_evaluation_view.xml
+++ b/addons/hr_evaluation/hr_evaluation_view.xml
@@ -306,6 +306,10 @@
<field name="response" readonly="1"/>
<field name="user_to_review_id"/>
<field name="user_id" string="Interviewer"/>
+ <button string="Send Reminder Email"
+ name="%(mail.action_email_compose_message_wizard)d"
+ icon="terp-mail-message-new" type="action" colspan="2"
+ states="waiting_answer"/>
</group>
<newline/>
<separator string="State" colspan="4"/>
@@ -329,6 +333,7 @@
<field name="response" readonly="1" invisible="True"/>
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" states="waiting_answer,done,cancel" icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': [response], 'response_no':0, 'active' : response, 'request' : True, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
<button name="%(survey.survey_browse_response)d" string="Print Interview" type="action" states="done" icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : [response], 'response_no':0}" attrs="{'readonly':[('response','=',False)]}" />
+ <button name="%(mail.action_email_compose_message_wizard)d" string="Send Reminder Email" icon="terp-mail-message-new" type="action" colspan="2" states="waiting_answer"/>
<field name="state"/>
</tree>
</field>
@@ -403,8 +408,16 @@
<menuitem name="Interview Requests" parent="menu_eval_hr" id="menu_open_hr_evaluation_interview_requests"
action="action_hr_evaluation_interview_tree"/>
- <menuitem name="Evaluation Reminders" parent="menu_eval_hr" id="menu_eval_send_mail"
- action="action_hr_evaluation_send_mail" sequence="45" groups="base.group_hr_manager"/>
+
+ <!-- Email Compose message Action-->
+ <act_window
+ id="evaluation_reminders" name="Evaluation Reminders"
+ res_model="mail.compose.message"
+ src_model="hr.evaluation.interview"
+ view_type="form" view_mode="form"
+ target="new" multi="True"
+ key2="client_action_multi"
+ context="{'mail.compose.message.mode':'mass_mail'}"/>
<!-- Evaluation Interviews Button on Employee Form -->
<act_window
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: