From 8bf484572f1942022dc85d77c6dcd9becf7e52d8 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 16 Sep 2014 13:03:36 +0200 Subject: [PATCH 1/8] Remove scheduler_error_mailer from __unported__. --HG-- extra : rebase_source : 31c71350725cc03390b156b452ff3b92b90e291f --- .../__init__.py | 0 .../__openerp__.py | 0 .../i18n/scheduler_error_mailer.pot | 0 .../images/scheduler_error_mailer.jpg | Bin .../ir_cron.py | 0 .../ir_cron.xml | 0 .../ir_cron_demo.xml | 0 .../ir_cron_email_tpl.xml | 0 .../static/src/img/icon.png | Bin 9 files changed, 0 insertions(+), 0 deletions(-) rename {__unported__/scheduler_error_mailer => scheduler_error_mailer}/__init__.py (100%) rename {__unported__/scheduler_error_mailer => scheduler_error_mailer}/__openerp__.py (100%) rename {__unported__/scheduler_error_mailer => scheduler_error_mailer}/i18n/scheduler_error_mailer.pot (100%) rename {__unported__/scheduler_error_mailer => scheduler_error_mailer}/images/scheduler_error_mailer.jpg (100%) rename {__unported__/scheduler_error_mailer => scheduler_error_mailer}/ir_cron.py (100%) rename {__unported__/scheduler_error_mailer => scheduler_error_mailer}/ir_cron.xml (100%) rename {__unported__/scheduler_error_mailer => scheduler_error_mailer}/ir_cron_demo.xml (100%) rename {__unported__/scheduler_error_mailer => scheduler_error_mailer}/ir_cron_email_tpl.xml (100%) rename {__unported__/scheduler_error_mailer => scheduler_error_mailer}/static/src/img/icon.png (100%) diff --git a/__unported__/scheduler_error_mailer/__init__.py b/scheduler_error_mailer/__init__.py similarity index 100% rename from __unported__/scheduler_error_mailer/__init__.py rename to scheduler_error_mailer/__init__.py diff --git a/__unported__/scheduler_error_mailer/__openerp__.py b/scheduler_error_mailer/__openerp__.py similarity index 100% rename from __unported__/scheduler_error_mailer/__openerp__.py rename to scheduler_error_mailer/__openerp__.py diff --git a/__unported__/scheduler_error_mailer/i18n/scheduler_error_mailer.pot b/scheduler_error_mailer/i18n/scheduler_error_mailer.pot similarity index 100% rename from __unported__/scheduler_error_mailer/i18n/scheduler_error_mailer.pot rename to scheduler_error_mailer/i18n/scheduler_error_mailer.pot diff --git a/__unported__/scheduler_error_mailer/images/scheduler_error_mailer.jpg b/scheduler_error_mailer/images/scheduler_error_mailer.jpg similarity index 100% rename from __unported__/scheduler_error_mailer/images/scheduler_error_mailer.jpg rename to scheduler_error_mailer/images/scheduler_error_mailer.jpg diff --git a/__unported__/scheduler_error_mailer/ir_cron.py b/scheduler_error_mailer/ir_cron.py similarity index 100% rename from __unported__/scheduler_error_mailer/ir_cron.py rename to scheduler_error_mailer/ir_cron.py diff --git a/__unported__/scheduler_error_mailer/ir_cron.xml b/scheduler_error_mailer/ir_cron.xml similarity index 100% rename from __unported__/scheduler_error_mailer/ir_cron.xml rename to scheduler_error_mailer/ir_cron.xml diff --git a/__unported__/scheduler_error_mailer/ir_cron_demo.xml b/scheduler_error_mailer/ir_cron_demo.xml similarity index 100% rename from __unported__/scheduler_error_mailer/ir_cron_demo.xml rename to scheduler_error_mailer/ir_cron_demo.xml diff --git a/__unported__/scheduler_error_mailer/ir_cron_email_tpl.xml b/scheduler_error_mailer/ir_cron_email_tpl.xml similarity index 100% rename from __unported__/scheduler_error_mailer/ir_cron_email_tpl.xml rename to scheduler_error_mailer/ir_cron_email_tpl.xml diff --git a/__unported__/scheduler_error_mailer/static/src/img/icon.png b/scheduler_error_mailer/static/src/img/icon.png similarity index 100% rename from __unported__/scheduler_error_mailer/static/src/img/icon.png rename to scheduler_error_mailer/static/src/img/icon.png From 4f31e54b751b34d24f8e9da7f52e1d74c646c8ba Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 16 Sep 2014 13:07:33 +0200 Subject: [PATCH 2/8] Make module installable. --HG-- extra : rebase_source : 91f540ebbedce6face2e0491f0f99b64e8025bb4 --- scheduler_error_mailer/__openerp__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scheduler_error_mailer/__openerp__.py b/scheduler_error_mailer/__openerp__.py index d1cf8fd95..c081508d0 100644 --- a/scheduler_error_mailer/__openerp__.py +++ b/scheduler_error_mailer/__openerp__.py @@ -43,6 +43,5 @@ This module adds the possibility to send an e-mail when a scheduler raises an er ], 'demo': ['ir_cron_demo.xml'], 'images': ['images/scheduler_error_mailer.jpg'], - 'installable': False, - 'active': False, + 'installable': True, } From 1ffe11ec2b9f4722d3ffd27bed57a7a914f35397 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 18 Sep 2014 14:00:26 +0200 Subject: [PATCH 3/8] Move icon. --HG-- rename : scheduler_error_mailer/static/src/img/icon.png => scheduler_error_mailer/static/description/icon.png --- .../static/{src/img => description}/icon.png | Bin 1 file changed, 0 insertions(+), 0 deletions(-) rename scheduler_error_mailer/static/{src/img => description}/icon.png (100%) diff --git a/scheduler_error_mailer/static/src/img/icon.png b/scheduler_error_mailer/static/description/icon.png similarity index 100% rename from scheduler_error_mailer/static/src/img/icon.png rename to scheduler_error_mailer/static/description/icon.png From d05b51f1ea44af17a76773a909ab795294298471 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 18 Sep 2014 14:01:48 +0200 Subject: [PATCH 4/8] Fix some formatting. --- scheduler_error_mailer/ir_cron.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scheduler_error_mailer/ir_cron.py b/scheduler_error_mailer/ir_cron.py index 8971da486..b1137a923 100644 --- a/scheduler_error_mailer/ir_cron.py +++ b/scheduler_error_mailer/ir_cron.py @@ -26,7 +26,8 @@ from openerp.osv import orm, fields from openerp.tools.translate import _ import logging -logger = logging.getLogger(__name__) + +_logger = logging.getLogger(__name__) class ir_cron(orm.Model): @@ -36,10 +37,12 @@ class ir_cron(orm.Model): 'email_template': fields.many2one( 'email.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) @@ -52,9 +55,11 @@ class ir_cron(orm.Model): 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, my_cron.email_template.id, my_cron.id, force_send=True, context=context) From 81d29937a51f4a56db424bfa2b432f288550c15b Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 18 Sep 2014 14:02:03 +0200 Subject: [PATCH 5/8] Only admin can send emails here. --- scheduler_error_mailer/ir_cron.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scheduler_error_mailer/ir_cron.py b/scheduler_error_mailer/ir_cron.py index b1137a923..512ac4996 100644 --- a/scheduler_error_mailer/ir_cron.py +++ b/scheduler_error_mailer/ir_cron.py @@ -22,6 +22,7 @@ # ############################################################################## +from openerp import SUPERUSER_ID from openerp.osv import orm, fields from openerp.tools.translate import _ import logging @@ -61,7 +62,7 @@ class ir_cron(orm.Model): context) 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) return res From 3ba101c45432adf555aeff2feca72e937f305071 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 18 Sep 2014 14:02:20 +0200 Subject: [PATCH 6/8] Don't pollute other models just for testing this one. --HG-- extra : amend_source : d3da15fc7b28f738dbef0e7a60044b4f71056b06 --- scheduler_error_mailer/ir_cron.py | 11 +++++------ scheduler_error_mailer/ir_cron_demo.xml | 5 ++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/scheduler_error_mailer/ir_cron.py b/scheduler_error_mailer/ir_cron.py index 512ac4996..17b0f2c30 100644 --- a/scheduler_error_mailer/ir_cron.py +++ b/scheduler_error_mailer/ir_cron.py @@ -67,10 +67,9 @@ class ir_cron(orm.Model): 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""" - raise orm.except_orm(_('Error :'), _("Task failure with UID = %d." % uid)) + + raise orm.except_orm( + _('Error :'), + _("Task failure with UID = %d.") % uid) diff --git a/scheduler_error_mailer/ir_cron_demo.xml b/scheduler_error_mailer/ir_cron_demo.xml index d8453b4bf..4c6fc5e7b 100644 --- a/scheduler_error_mailer/ir_cron_demo.xml +++ b/scheduler_error_mailer/ir_cron_demo.xml @@ -18,9 +18,8 @@ -1 - - - + ir.cron + _test_scheduler_failure From bfb3bfcdcf1d109e2943d2f3bd0fa59671ea8f3c Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 18 Sep 2014 14:02:43 +0200 Subject: [PATCH 7/8] New translation template. --- .../i18n/scheduler_error_mailer.pot | 68 +++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/scheduler_error_mailer/i18n/scheduler_error_mailer.pot b/scheduler_error_mailer/i18n/scheduler_error_mailer.pot index c83ab22af..95fe5ca84 100644 --- a/scheduler_error_mailer/i18n/scheduler_error_mailer.pot +++ b/scheduler_error_mailer/i18n/scheduler_error_mailer.pot @@ -1,12 +1,13 @@ -# Translation of OpenERP Server. +# Translation of Odoo Server. # This file contains the translation of the following modules: +# * scheduler_error_mailer # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" +"Project-Id-Version: Odoo Server 8.0rc1\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" +"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" @@ -14,3 +15,62 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: scheduler_error_mailer +#: model:email.template,body_html:scheduler_error_mailer.scheduler_error_mailer +msgid "\n" +"
\n" +"\n" +"

OpenERP tried to run the scheduler ${object.name or ''} in the database ${ctx.get('dbname')} but it failed. Here is the error message :

\n" +"\n" +"\n" +"${ctx.get('job_exception') and ctx.get('job_exception').value or 'Failed to get the error message from the context.'}\n" +"\n" +"\n" +"

You may check the logs of the OpenERP server to get more information about this failure.

\n" +"\n" +"

Properties of the scheduler ${object.name or ''} :

\n" +"
    \n" +"
  • Model : ${object.model or ''}
  • \n" +"
  • Method : ${object.function or ''}
  • \n" +"
  • Arguments : ${object.args or ''}
  • \n" +"
  • Interval : ${object.interval_number or '0'} ${object.interval_type or ''}
  • \n" +"
  • Number of calls : ${object.numbercall or '0'}
  • \n" +"
  • Repeat missed : ${object.doall}
  • \n" +"
  • User : ${object.user_id.name or ''}
  • \n" +"
\n" +"\n" +"

\n" +"--
\n" +"Automatic e-mail sent by OpenERP. Do not reply.
\n" +"Database : ${ctx.get('dbname')}\n" +"

\n" +"
\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 "" From 56e760bf2bdb10b3080eace834863f79194a21ba Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Fri, 19 Sep 2014 13:54:05 +0200 Subject: [PATCH 8/8] PEP8 fix. --- scheduler_error_mailer/__openerp__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scheduler_error_mailer/__openerp__.py b/scheduler_error_mailer/__openerp__.py index c081508d0..a34e58b34 100644 --- a/scheduler_error_mailer/__openerp__.py +++ b/scheduler_error_mailer/__openerp__.py @@ -33,7 +33,8 @@ 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', 'website': 'http://www.akretion.com/', 'depends': ['email_template'],