Browse Source

Merge pull request #80 from grupoesoc/scheduler_error_mailer

Scheduler error mailer
pull/93/head
Pedro M. Baeza 10 years ago
parent
commit
82319f78a3
  1. 16
      __unported__/scheduler_error_mailer/i18n/scheduler_error_mailer.pot
  2. 0
      scheduler_error_mailer/__init__.py
  3. 6
      scheduler_error_mailer/__openerp__.py
  4. 76
      scheduler_error_mailer/i18n/scheduler_error_mailer.pot
  5. 0
      scheduler_error_mailer/images/scheduler_error_mailer.jpg
  6. 29
      scheduler_error_mailer/ir_cron.py
  7. 0
      scheduler_error_mailer/ir_cron.xml
  8. 5
      scheduler_error_mailer/ir_cron_demo.xml
  9. 0
      scheduler_error_mailer/ir_cron_email_tpl.xml
  10. 0
      scheduler_error_mailer/static/description/icon.png

16
__unported__/scheduler_error_mailer/i18n/scheduler_error_mailer.pot

@ -1,16 +0,0 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-03-14 17:41+0000\n"
"PO-Revision-Date: 2014-03-14 17:41+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

0
__unported__/scheduler_error_mailer/__init__.py → scheduler_error_mailer/__init__.py

6
__unported__/scheduler_error_mailer/__openerp__.py → scheduler_error_mailer/__openerp__.py

@ -33,7 +33,8 @@
Scheduler Error Mailer Scheduler Error Mailer
====================== ======================
This module adds the possibility to send an e-mail when a scheduler raises an error.""",
This module adds the possibility to send an e-mail when a scheduler raises
an error.""",
'author': 'Akretion', 'author': 'Akretion',
'website': 'http://www.akretion.com/', 'website': 'http://www.akretion.com/',
'depends': ['email_template'], 'depends': ['email_template'],
@ -43,6 +44,5 @@ This module adds the possibility to send an e-mail when a scheduler raises an er
], ],
'demo': ['ir_cron_demo.xml'], 'demo': ['ir_cron_demo.xml'],
'images': ['images/scheduler_error_mailer.jpg'], 'images': ['images/scheduler_error_mailer.jpg'],
'installable': False,
'active': False,
'installable': True,
} }

76
scheduler_error_mailer/i18n/scheduler_error_mailer.pot

@ -0,0 +1,76 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * scheduler_error_mailer
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0rc1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-09-18 11:55+0000\n"
"PO-Revision-Date: 2014-09-18 11:55+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: scheduler_error_mailer
#: model:email.template,body_html:scheduler_error_mailer.scheduler_error_mailer
msgid "\n"
"<div style=\"font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; \">\n"
"\n"
"<p>OpenERP tried to run the scheduler <em>${object.name or ''}</em> in the database <em>${ctx.get('dbname')}</em> but it failed. Here is the error message :</p>\n"
"\n"
"<strong>\n"
"${ctx.get('job_exception') and ctx.get('job_exception').value or 'Failed to get the error message from the context.'}\n"
"</strong>\n"
"\n"
"<p>You may check the logs of the OpenERP server to get more information about this failure.</p>\n"
"\n"
"<p>Properties of the scheduler <em>${object.name or ''}</em> :</p>\n"
"<ul>\n"
"<li>Model : ${object.model or ''}</li>\n"
"<li>Method : ${object.function or ''}</li>\n"
"<li>Arguments : ${object.args or ''}</li>\n"
"<li>Interval : ${object.interval_number or '0'} ${object.interval_type or ''}</li>\n"
"<li>Number of calls : ${object.numbercall or '0'}</li>\n"
"<li>Repeat missed : ${object.doall}</li>\n"
"<li>User : ${object.user_id.name or ''}</li>\n"
"</ul>\n"
"\n"
"<p>\n"
"-- <br/>\n"
"Automatic e-mail sent by OpenERP. Do not reply.<br/>\n"
"Database : ${ctx.get('dbname')}\n"
"</p>\n"
"</div>\n"
" "
msgstr ""
#. module: scheduler_error_mailer
#: code:addons/scheduler_error_mailer/ir_cron.py:74
#, python-format
msgid "Error :"
msgstr ""
#. module: scheduler_error_mailer
#: field:ir.cron,email_template:0
msgid "Error E-mail Template"
msgstr ""
#. module: scheduler_error_mailer
#: help:ir.cron,email_template:0
msgid "Select the email template that will be sent when this scheduler fails."
msgstr ""
#. module: scheduler_error_mailer
#: code:addons/scheduler_error_mailer/ir_cron.py:75
#, python-format
msgid "Task failure with UID = %d."
msgstr ""
#. module: scheduler_error_mailer
#: model:email.template,subject:scheduler_error_mailer.scheduler_error_mailer
msgid "[DB ${ctx.get('dbname')}] Scheduler '${object.name or ''}' FAILED"
msgstr ""

0
__unported__/scheduler_error_mailer/images/scheduler_error_mailer.jpg → scheduler_error_mailer/images/scheduler_error_mailer.jpg

Before

Width: 900  |  Height: 364  |  Size: 29 KiB

After

Width: 900  |  Height: 364  |  Size: 29 KiB

29
__unported__/scheduler_error_mailer/ir_cron.py → scheduler_error_mailer/ir_cron.py

@ -22,11 +22,13 @@
# #
############################################################################## ##############################################################################
from openerp import SUPERUSER_ID
from openerp.osv import orm, fields from openerp.osv import orm, fields
from openerp.tools.translate import _ from openerp.tools.translate import _
import logging import logging
logger = logging.getLogger(__name__)
_logger = logging.getLogger(__name__)
class ir_cron(orm.Model): class ir_cron(orm.Model):
@ -36,10 +38,12 @@ class ir_cron(orm.Model):
'email_template': fields.many2one( 'email_template': fields.many2one(
'email.template', '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( res = super(ir_cron, self)._handle_callback_exception(
cr, uid, model_name, method_name, args, job_id, job_exception) cr, uid, model_name, method_name, args, job_id, job_exception)
@ -52,19 +56,20 @@ class ir_cron(orm.Model):
context = { context = {
'job_exception': job_exception, 'job_exception': job_exception,
'dbname': cr.dbname, 'dbname': cr.dbname,
}
}
_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( self.pool['email.template'].send_mail(
cr, uid, my_cron.email_template.id, my_cron.id,
cr, SUPERUSER_ID, my_cron.email_template.id, my_cron.id,
force_send=True, context=context) force_send=True, context=context)
return res return res
class res_users(orm.Model):
_inherit = 'res.users'
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)

0
__unported__/scheduler_error_mailer/ir_cron.xml → scheduler_error_mailer/ir_cron.xml

5
__unported__/scheduler_error_mailer/ir_cron_demo.xml → scheduler_error_mailer/ir_cron_demo.xml

@ -18,9 +18,8 @@
<field name="numbercall">-1</field> <!-- don't limit the number of calls --> <field name="numbercall">-1</field> <!-- don't limit the number of calls -->
<field name="doall" eval="True"/> <field name="doall" eval="True"/>
<field name="email_template" ref="scheduler_error_mailer"/> <field name="email_template" ref="scheduler_error_mailer"/>
<field name="model" eval="'res.users'"/>
<field name="function" eval="'test_scheduler_failure'" />
<field name="args" eval="'()'"/>
<field name="model">ir.cron</field>
<field name="function">_test_scheduler_failure</field>
</record> </record>
</data> </data>

0
__unported__/scheduler_error_mailer/ir_cron_email_tpl.xml → scheduler_error_mailer/ir_cron_email_tpl.xml

0
__unported__/scheduler_error_mailer/static/src/img/icon.png → scheduler_error_mailer/static/description/icon.png

Before

Width: 64  |  Height: 64  |  Size: 4.9 KiB

After

Width: 64  |  Height: 64  |  Size: 4.9 KiB

Loading…
Cancel
Save