Browse Source

Implement the suggestion of Stefan Rijnhart to get the name of the DB in the email.

pull/2/head
Alexis de Lattre 11 years ago
parent
commit
7d0294b56b
  1. 6
      scheduler_error_mailer/ir_cron.py
  2. 8
      scheduler_error_mailer/ir_cron_email_tpl.xml

6
scheduler_error_mailer/ir_cron.py

@ -48,7 +48,11 @@ class ir_cron(orm.Model):
if my_cron.email_template: if my_cron.email_template:
# we put the job_exception in context to be able to print it inside # we put the job_exception in context to be able to print it inside
# the email template # the email template
context = {'job_exception': job_exception}
context = {
'job_exception': job_exception,
'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(cr, uid, self.pool['email.template'].send_mail(cr, uid,
my_cron.email_template.id, my_cron.id, force_send=True, my_cron.email_template.id, my_cron.id, force_send=True,

8
scheduler_error_mailer/ir_cron_email_tpl.xml

@ -12,13 +12,13 @@
<field name="name">Scheduler Error</field> <field name="name">Scheduler Error</field>
<field name="email_from">${object.user_id.user_email or ''}</field> <field name="email_from">${object.user_id.user_email or ''}</field>
<field name="email_to">${object.user_id.user_email or ''}</field> <field name="email_to">${object.user_id.user_email or ''}</field>
<field name="subject">Scheduler '${object.name or ''}' FAILED</field>
<field name="subject">[DB ${ctx.get('dbname')}] Scheduler '${object.name or ''}' FAILED</field>
<field name="model_id" ref="base.model_ir_cron"/> <field name="model_id" ref="base.model_ir_cron"/>
<field name="auto_delete" eval="True"/> <field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
<p>OpenERP tried to run the scheduler <em>${object.name or ''}</em> but it failed. Here is the error message :</p>
<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>
<strong> <strong>
${ctx.get('job_exception') and ctx.get('job_exception').value or 'Failed to get the error message from the context.'} ${ctx.get('job_exception') and ctx.get('job_exception').value or 'Failed to get the error message from the context.'}
@ -39,12 +39,12 @@ ${ctx.get('job_exception') and ctx.get('job_exception').value or 'Failed to get
<p> <p>
-- <br/> -- <br/>
Automatic e-mail sent by OpenERP. Do not reply.
Automatic e-mail sent by OpenERP. Do not reply.<br/>
Database : ${ctx.get('dbname')}
</p> </p>
</div> </div>
]]></field> ]]></field>
</record> </record>
<!-- TODO : print database name inside the email (we used object._cr.dbname in openerp 6.1, but it's not possible in OpenERP 7 because the executing of jinja2 is sandboxed and private attributes can't be accessed). -->
</data> </data>
</openerp> </openerp>
Loading…
Cancel
Save