Browse Source

[ADD] scheduler_error_mailer: show the traceback, don't expect all exceptions to fill value (#813)

pull/329/head
Holger Brunn 8 years ago
committed by Pedro M. Baeza
parent
commit
4ad794fe18
  1. 8
      scheduler_error_mailer/ir_cron.py
  2. 8
      scheduler_error_mailer/ir_cron_email_tpl.xml

8
scheduler_error_mailer/ir_cron.py

@ -21,11 +21,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
import logging
import sys
import traceback
from openerp import SUPERUSER_ID 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
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@ -57,6 +58,9 @@ class ir_cron(orm.Model):
context = { context = {
'job_exception': job_exception, 'job_exception': job_exception,
'dbname': cr.dbname, 'dbname': cr.dbname,
'traceback': '\n'.join(
traceback.format_exception(*sys.exc_info())
),
} }
_logger.debug("Sending scheduler error email with context=%s", _logger.debug("Sending scheduler error email with context=%s",

8
scheduler_error_mailer/ir_cron_email_tpl.xml

@ -18,12 +18,16 @@
<field name="body_html"><![CDATA[ <field name="body_html"><![CDATA[
<div style="font-family: 'Lucida Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> <div style="font-family: 'Lucida 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> in the database <em>${ctx.get('dbname')}</em> but it failed. Here is the error message :</p>
<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> <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') or 'Failed to get the error message from the context.'|e}
</strong> </strong>
<pre>
${ctx.get('traceback')|e}
</pre>
<p>You may check the logs of the Odoo server to get more information about this failure.</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> <p>Properties of the scheduler <em>${object.name or ''}</em> :</p>

Loading…
Cancel
Save