Skip to content

Commit

Permalink
Merge f5b0b7b into 7ab7bb4
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsergio committed Sep 20, 2019
2 parents 7ab7bb4 + f5b0b7b commit 10c240e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 12 additions & 3 deletions scheduler_error_mailer/data/ir_cron_email_tpl.xml
Expand Up @@ -18,15 +18,24 @@
<p>Odoo 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>
${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 ctx.get('job_exception').name) or 'Failed to get the error message from the context.'}
</strong>
<p>
<strong>
% for trace_line in ctx.get('trace_exception'):
<span>${trace_line}</span>
<br/>
% endfor
</strong>
</p
<p>You may check the logs of the Odoo server to get more information about this failure.</p>
<p>Properties of the scheduler <em>${object.name or ''}</em> :</p>
<ul>
<li>Model : ${object.model or ''}</li>
<li>Method : ${object.function or ''}</li>
<li>Model : ${object.model_id.name or ''}</li>
<li>Method : ${object.code or ''}</li>
<li>Arguments : ${object.args or ''}</li>
<li>Interval : ${object.interval_number or '0'} ${object.interval_type or ''}</li>
<li>Number of calls : ${object.numbercall or '0'}</li>
Expand Down
5 changes: 5 additions & 0 deletions scheduler_error_mailer/models/ir_cron.py
Expand Up @@ -6,6 +6,7 @@
from odoo import _, api, fields, models
from odoo.exceptions import UserError
import logging
import traceback


_logger = logging.getLogger(__name__)
Expand All @@ -31,11 +32,15 @@ def _handle_callback_exception(self, cron_name, server_action_id, job_id,
my_cron = self.browse(job_id)

if my_cron.email_template_id:
# catching the trace error
trace = traceback.format_exc()

# we put the job_exception in context to be able to print it inside
# the email template
context = {
'job_exception': job_exception,
'dbname': self._cr.dbname,
'trace_exception': trace.split("\n") if trace else "",
}

_logger.debug(
Expand Down

0 comments on commit 10c240e

Please sign in to comment.