|
@ -1,5 +1,5 @@ |
|
|
# -*- encoding: utf-8 -*- |
|
|
# -*- encoding: utf-8 -*- |
|
|
################################################################################# |
|
|
|
|
|
|
|
|
############################################################################## |
|
|
# |
|
|
# |
|
|
# Scheduler Error Mailer module for OpenERP |
|
|
# Scheduler Error Mailer module for OpenERP |
|
|
# Copyright (C) 2012-2013 Akretion (http://www.akretion.com/) |
|
|
# Copyright (C) 2012-2013 Akretion (http://www.akretion.com/) |
|
@ -28,20 +28,21 @@ import logging |
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ir_cron(orm.Model): |
|
|
class ir_cron(orm.Model): |
|
|
_inherit = "ir.cron" |
|
|
_inherit = "ir.cron" |
|
|
|
|
|
|
|
|
_columns = { |
|
|
_columns = { |
|
|
'email_template': fields.many2one('email.template', |
|
|
|
|
|
|
|
|
'email_template': fields.many2one( |
|
|
|
|
|
'email.template', |
|
|
'Error E-mail Template', |
|
|
'Error E-mail Template', |
|
|
help="Select the email template that will be sent when this scheduler fails."), |
|
|
help="Select the email template that will be sent when this scheduler fails."), |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _handle_callback_exception(self, cr, uid, model_name, method_name, args, job_id, job_exception): |
|
|
def _handle_callback_exception(self, cr, uid, model_name, method_name, args, job_id, job_exception): |
|
|
|
|
|
|
|
|
res = super(ir_cron, self)._handle_callback_exception(cr, uid, |
|
|
|
|
|
model_name, method_name, args, job_id, job_exception) |
|
|
|
|
|
|
|
|
res = super(ir_cron, self)._handle_callback_exception( |
|
|
|
|
|
cr, uid, model_name, method_name, args, job_id, job_exception) |
|
|
|
|
|
|
|
|
my_cron = self.browse(cr, uid, job_id) |
|
|
my_cron = self.browse(cr, uid, job_id) |
|
|
|
|
|
|
|
@ -54,9 +55,9 @@ class ir_cron(orm.Model): |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
logger.debug("Sending scheduler error email with context=%s" % context) |
|
|
logger.debug("Sending scheduler error email with context=%s" % context) |
|
|
self.pool['email.template'].send_mail(cr, uid, |
|
|
|
|
|
my_cron.email_template.id, my_cron.id, force_send=True, |
|
|
|
|
|
context=context) |
|
|
|
|
|
|
|
|
self.pool['email.template'].send_mail( |
|
|
|
|
|
cr, uid, my_cron.email_template.id, my_cron.id, |
|
|
|
|
|
force_send=True, context=context) |
|
|
|
|
|
|
|
|
return res |
|
|
return res |
|
|
|
|
|
|
|
@ -67,4 +68,3 @@ class res_users(orm.Model): |
|
|
def test_scheduler_failure(self, cr, uid, context=None): |
|
|
def test_scheduler_failure(self, cr, uid, context=None): |
|
|
"""This function is used to test and debug this module""" |
|
|
"""This function is used to test and debug this module""" |
|
|
raise orm.except_orm(_('Error :'), _("Task failure with UID = %d." % uid)) |
|
|
raise orm.except_orm(_('Error :'), _("Task failure with UID = %d." % uid)) |
|
|
|
|
|
|