diff --git a/scheduler_error_mailer/README.rst b/scheduler_error_mailer/README.rst new file mode 100644 index 000000000..269dec34c --- /dev/null +++ b/scheduler_error_mailer/README.rst @@ -0,0 +1,67 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +====================== +Scheduler Error Mailer +====================== + +This module adds the possibility to send an e-mail when a scheduler raises +an error. + +Configuration +============= + +To configure this module, you need to: + +#. Go to Settings -> Technical -> Automation -> Scheduled Actions +#. Choose the scheduled Actions you want to send the error email and select the E-mail Template in the Error E-mail Template field. + +Usage +===== + +To use this module, you need to: + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/149/9.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Sébastien BEAU +* David Beal +* Alexis de Lattre +* Sodexis + + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/scheduler_error_mailer/__init__.py b/scheduler_error_mailer/__init__.py index 36504c54b..cca6d9455 100644 --- a/scheduler_error_mailer/__init__.py +++ b/scheduler_error_mailer/__init__.py @@ -1,24 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Scheduler Error Mailer module for OpenERP -# Copyright (C) 2012-2013 Akretion (http://www.akretion.com/) -# @author: Sébastien Beau -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2012-2013 Akretion Sébastien BEAU,David Beal,Alexis de Lattre +# © 2016 Sodexis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from . import ir_cron +from . import models diff --git a/scheduler_error_mailer/__openerp__.py b/scheduler_error_mailer/__openerp__.py index d8dd3eb36..cee08d1c7 100644 --- a/scheduler_error_mailer/__openerp__.py +++ b/scheduler_error_mailer/__openerp__.py @@ -1,48 +1,21 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Scheduler Error Mailer module for OpenERP -# Copyright (C) 2012-2013 Akretion (http://www.akretion.com/) -# @author: Sébastien Beau -# @author David Beal -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - +# -*- coding: utf-8 -*- +# © 2012-2013 Akretion Sébastien BEAU,David Beal,Alexis de Lattre +# © 2016 Sodexis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Scheduler Error Mailer', - 'summary': 'Send an e-mail when a scheduler fails', - 'version': '8.0.1.0.0', + 'version': '9.0.1.0.0', 'category': 'Extra Tools', 'license': 'AGPL-3', - 'description': """ -Scheduler Error Mailer -====================== - -This module adds the possibility to send an e-mail when a scheduler raises -an error.""", - 'author': "Akretion,Odoo Community Association (OCA)", + 'author': "Akretion,Sodexis,Odoo Community Association (OCA)", 'website': 'http://www.akretion.com/', - 'depends': ['email_template'], + 'depends': ['mail'], 'data': [ - 'ir_cron.xml', - 'ir_cron_email_tpl.xml', + 'data/ir_cron_email_tpl.xml', + 'views/ir_cron.xml', ], - 'demo': ['ir_cron_demo.xml'], + 'demo': ['demo/ir_cron_demo.xml'], 'images': ['images/scheduler_error_mailer.jpg'], 'installable': True, } diff --git a/scheduler_error_mailer/ir_cron_email_tpl.xml b/scheduler_error_mailer/data/ir_cron_email_tpl.xml similarity index 58% rename from scheduler_error_mailer/ir_cron_email_tpl.xml rename to scheduler_error_mailer/data/ir_cron_email_tpl.xml index d0bd7859b..b8e6a2598 100644 --- a/scheduler_error_mailer/ir_cron_email_tpl.xml +++ b/scheduler_error_mailer/data/ir_cron_email_tpl.xml @@ -1,21 +1,24 @@ - - + + - - - Scheduler Error - ${object.user_id.user_email or ''} - ${object.user_id.user_email or ''} - [DB ${ctx.get('dbname')}] Scheduler '${object.name or ''}' FAILED - - - + + Scheduler Error + ${object.user_id.email or ''} + ${object.user_id.email or ''} + [DB ${ctx.get('dbname')}] Scheduler '${object.name or ''}' FAILED + + + +

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

@@ -43,8 +46,9 @@ Automatic e-mail sent by OpenERP. Do not reply.
Database : ${ctx.get('dbname')}

- ]]>
-
+ ]]> +
+
-
-
+ + diff --git a/scheduler_error_mailer/demo/ir_cron_demo.xml b/scheduler_error_mailer/demo/ir_cron_demo.xml new file mode 100644 index 000000000..08368e8e7 --- /dev/null +++ b/scheduler_error_mailer/demo/ir_cron_demo.xml @@ -0,0 +1,27 @@ + + + + + + + + Test Scheduler Error Mailer + + + 1 + hours + -1 + + + ir.cron + _test_scheduler_failure + + + + + diff --git a/scheduler_error_mailer/i18n/en.po b/scheduler_error_mailer/i18n/en.po deleted file mode 100644 index 002a624c9..000000000 --- a/scheduler_error_mailer/i18n/en.po +++ /dev/null @@ -1,79 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * scheduler_error_mailer -# -# Translators: -msgid "" -msgstr "" -"Project-Id-Version: server-tools (8.0)\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-09-29 11:14+0000\n" -"PO-Revision-Date: 2015-09-18 13:56+0000\n" -"Last-Translator: OCA Transbot \n" -"Language-Team: English (http://www.transifex.com/oca/OCA-server-tools-8-0/language/en/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: en\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\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 "\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--
\nAutomatic e-mail sent by OpenERP. Do not reply.
\nDatabase : ${ctx.get('dbname')}\n

\n
\n " - -#. module: scheduler_error_mailer -#: code:addons/scheduler_error_mailer/ir_cron.py:75 -#, python-format -msgid "Error :" -msgstr "Error :" - -#. module: scheduler_error_mailer -#: field:ir.cron,email_template_id:0 -msgid "Error E-mail Template" -msgstr "Error E-mail Template" - -#. module: scheduler_error_mailer -#: help:ir.cron,email_template_id:0 -msgid "Select the email template that will be sent when this scheduler fails." -msgstr "Select the email template that will be sent when this scheduler fails." - -#. module: scheduler_error_mailer -#: code:addons/scheduler_error_mailer/ir_cron.py:76 -#, python-format -msgid "Task failure with UID = %d." -msgstr "Task failure with UID = %d." - -#. 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 "[DB ${ctx.get('dbname')}] Scheduler '${object.name or ''}' FAILED" diff --git a/scheduler_error_mailer/i18n/pt_BR.po b/scheduler_error_mailer/i18n/pt_BR.po index 4ad2412b1..beacbdd1c 100644 --- a/scheduler_error_mailer/i18n/pt_BR.po +++ b/scheduler_error_mailer/i18n/pt_BR.po @@ -3,15 +3,15 @@ # * scheduler_error_mailer # # Translators: -# Armando Vulcano Junior , 2015 +# OCA Transbot , 2016 msgid "" msgstr "" -"Project-Id-Version: server-tools (8.0)\n" +"Project-Id-Version: Odoo Server 9.0c\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-09-29 11:14+0000\n" -"PO-Revision-Date: 2015-09-18 23:44+0000\n" -"Last-Translator: Armando Vulcano Junior \n" -"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-server-tools-8-0/language/pt_BR/)\n" +"POT-Creation-Date: 2016-08-06 02:49+0000\n" +"PO-Revision-Date: 2016-08-06 02:49+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" @@ -19,9 +19,10 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: scheduler_error_mailer -#: model:email.template,body_html:scheduler_error_mailer.scheduler_error_mailer +#: model:mail.template,body_html:scheduler_error_mailer.scheduler_error_mailer msgid "" "\n" +" \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" @@ -49,32 +50,33 @@ msgid "" "Database : ${ctx.get('dbname')}\n" "

\n" "
\n" -" " +" \n" +" " msgstr "" #. module: scheduler_error_mailer -#: code:addons/scheduler_error_mailer/ir_cron.py:75 -#, python-format -msgid "Error :" -msgstr "Erro" - -#. module: scheduler_error_mailer -#: field:ir.cron,email_template_id:0 +#: model:ir.model.fields,field_description:scheduler_error_mailer.field_ir_cron_email_template_id msgid "Error E-mail Template" msgstr "Modelo de Erro de E-mail" #. module: scheduler_error_mailer -#: help:ir.cron,email_template_id:0 +#: model:ir.model.fields,help:scheduler_error_mailer.field_ir_cron_email_template_id msgid "Select the email template that will be sent when this scheduler fails." -msgstr "Selecione o modelo de email que será enviado quando o agendador falhar." +msgstr "" +"Selecione o modelo de email que será enviado quando o agendador falhar." #. module: scheduler_error_mailer -#: code:addons/scheduler_error_mailer/ir_cron.py:76 +#: code:addons/scheduler_error_mailer/models/ir_cron.py:55 #, python-format msgid "Task failure with UID = %d." msgstr "Tarefa falhou com UID = %d." #. module: scheduler_error_mailer -#: model:email.template,subject:scheduler_error_mailer.scheduler_error_mailer +#: model:mail.template,subject:scheduler_error_mailer.scheduler_error_mailer msgid "[DB ${ctx.get('dbname')}] Scheduler '${object.name or ''}' FAILED" msgstr "[DB ${ctx.get('dbname')}] Agendador '${object.name or ''}' FALHOU" + +#. module: scheduler_error_mailer +#: model:ir.model,name:scheduler_error_mailer.model_ir_cron +msgid "ir.cron" +msgstr "" diff --git a/scheduler_error_mailer/i18n/sl.po b/scheduler_error_mailer/i18n/sl.po index 821a93011..13ac3181b 100644 --- a/scheduler_error_mailer/i18n/sl.po +++ b/scheduler_error_mailer/i18n/sl.po @@ -3,15 +3,15 @@ # * scheduler_error_mailer # # Translators: -# Matjaž Mozetič , 2015 +# OCA Transbot , 2016 msgid "" msgstr "" -"Project-Id-Version: server-tools (8.0)\n" +"Project-Id-Version: Odoo Server 9.0c\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-09-29 11:14+0000\n" -"PO-Revision-Date: 2015-09-26 07:36+0000\n" -"Last-Translator: Matjaž Mozetič \n" -"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-server-tools-8-0/language/sl/)\n" +"POT-Creation-Date: 2016-08-06 02:49+0000\n" +"PO-Revision-Date: 2016-08-06 02:49+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" @@ -19,9 +19,10 @@ msgstr "" "Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" #. module: scheduler_error_mailer -#: model:email.template,body_html:scheduler_error_mailer.scheduler_error_mailer +#: model:mail.template,body_html:scheduler_error_mailer.scheduler_error_mailer msgid "" "\n" +" \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" @@ -49,32 +50,33 @@ msgid "" "Database : ${ctx.get('dbname')}\n" "

\n" "
\n" -" " -msgstr "\n
\n\n

OpenERP je poskušal zagnati razporejevalec ${object.name or ''} v podatkovni bazi ${ctx.get('dbname')} , a ni uspel. Obvestilo o napaki:

\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

Preverite dnevnike OpenERP strežnika za pridobitev več informacij o težavi.

\n\n

Lastnosti razporejevalca ${object.name or ''} :

\n
    \n
  • Model : ${object.model or ''}
  • \n
  • Metoda : ${object.function or ''}
  • \n
  • Argumenti : ${object.args or ''}
  • \n
  • Interval : ${object.interval_number or '0'} ${object.interval_type or ''}
  • \n
  • Število klicev : ${object.numbercall or '0'}
  • \n
  • Zgrešene ponovitve : ${object.doall}
  • \n
  • Uporabnik : ${object.user_id.name or ''}
  • \n
\n\n

\n--
\nSamodejno sporočilo poslano iz OpenERP. Ne odgovarjajte.
\nPodatkovna baza : ${ctx.get('dbname')}\n

\n
\n " +" \n" +" " +msgstr "" #. module: scheduler_error_mailer -#: code:addons/scheduler_error_mailer/ir_cron.py:75 -#, python-format -msgid "Error :" -msgstr "Napaka:" - -#. module: scheduler_error_mailer -#: field:ir.cron,email_template_id:0 +#: model:ir.model.fields,field_description:scheduler_error_mailer.field_ir_cron_email_template_id msgid "Error E-mail Template" msgstr "Predloga obvestila o napaki" #. module: scheduler_error_mailer -#: help:ir.cron,email_template_id:0 +#: model:ir.model.fields,help:scheduler_error_mailer.field_ir_cron_email_template_id msgid "Select the email template that will be sent when this scheduler fails." msgstr "Izberite predlogo za razpošiljanje ob napakah razporejevalca." #. module: scheduler_error_mailer -#: code:addons/scheduler_error_mailer/ir_cron.py:76 +#: code:addons/scheduler_error_mailer/models/ir_cron.py:55 #, python-format msgid "Task failure with UID = %d." msgstr "Napaka pri opravilu UID = %d." #. module: scheduler_error_mailer -#: model:email.template,subject:scheduler_error_mailer.scheduler_error_mailer +#: model:mail.template,subject:scheduler_error_mailer.scheduler_error_mailer msgid "[DB ${ctx.get('dbname')}] Scheduler '${object.name or ''}' FAILED" -msgstr "[DB ${ctx.get('dbname')}] Razporejevalec '${object.name or ''}' NEUSPEŠEN" +msgstr "" +"[DB ${ctx.get('dbname')}] Razporejevalec '${object.name or ''}' NEUSPEŠEN" + +#. module: scheduler_error_mailer +#: model:ir.model,name:scheduler_error_mailer.model_ir_cron +msgid "ir.cron" +msgstr "" diff --git a/scheduler_error_mailer/i18n/zh_CN.po b/scheduler_error_mailer/i18n/zh_CN.po new file mode 100644 index 000000000..f312e6e0c --- /dev/null +++ b/scheduler_error_mailer/i18n/zh_CN.po @@ -0,0 +1,81 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * scheduler_error_mailer +# +# Translators: +# Jeffery Chenn , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-08-31 11:58+0000\n" +"PO-Revision-Date: 2016-08-31 11:58+0000\n" +"Last-Translator: Jeffery Chenn , 2016\n" +"Language-Team: Chinese (China) (https://www.transifex.com/oca/teams/23907/zh_CN/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: zh_CN\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#. module: scheduler_error_mailer +#: model:mail.template,body_html:scheduler_error_mailer.scheduler_error_mailer +msgid "" +"\n" +" \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" +" \n" +" " +msgstr "" + +#. module: scheduler_error_mailer +#: model:ir.model.fields,field_description:scheduler_error_mailer.field_ir_cron_email_template_id +msgid "Error E-mail Template" +msgstr "错误E-mail 模板" + +#. module: scheduler_error_mailer +#: model:ir.model.fields,help:scheduler_error_mailer.field_ir_cron_email_template_id +msgid "Select the email template that will be sent when this scheduler fails." +msgstr "" + +#. module: scheduler_error_mailer +#: code:addons/scheduler_error_mailer/models/ir_cron.py:55 +#, python-format +msgid "Task failure with UID = %d." +msgstr "" + +#. module: scheduler_error_mailer +#: model:mail.template,subject:scheduler_error_mailer.scheduler_error_mailer +msgid "[DB ${ctx.get('dbname')}] Scheduler '${object.name or ''}' FAILED" +msgstr "" + +#. module: scheduler_error_mailer +#: model:ir.model,name:scheduler_error_mailer.model_ir_cron +msgid "ir.cron" +msgstr "" diff --git a/scheduler_error_mailer/ir_cron.py b/scheduler_error_mailer/ir_cron.py deleted file mode 100644 index 548728bf4..000000000 --- a/scheduler_error_mailer/ir_cron.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Scheduler Error Mailer module for OpenERP -# Copyright (C) 2012-2013 Akretion (http://www.akretion.com/) -# @author: Sébastien Beau -# @author David Beal -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp import SUPERUSER_ID -from openerp.osv import orm, fields -from openerp.tools.translate import _ -import logging - - -_logger = logging.getLogger(__name__) - - -class ir_cron(orm.Model): - _inherit = "ir.cron" - - _columns = { - 'email_template_id': fields.many2one( - 'email.template', - 'Error E-mail Template', - oldname="email_template", - 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): - - res = super(ir_cron, self)._handle_callback_exception( - cr, uid, model_name, method_name, args, job_id, job_exception) - - my_cron = self.browse(cr, uid, job_id) - - if my_cron.email_template_id: - # we put the job_exception in context to be able to print it inside - # the email template - context = { - 'job_exception': job_exception, - 'dbname': cr.dbname, - } - - _logger.debug("Sending scheduler error email with context=%s", - context) - - self.pool['email.template'].send_mail( - cr, SUPERUSER_ID, my_cron.email_template_id.id, my_cron.id, - force_send=True, context=context) - - return res - - 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) diff --git a/scheduler_error_mailer/ir_cron.xml b/scheduler_error_mailer/ir_cron.xml deleted file mode 100644 index 74a3d3edf..000000000 --- a/scheduler_error_mailer/ir_cron.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - ir.cron.error.mailer.form - ir.cron - - - - - - - - - - - diff --git a/scheduler_error_mailer/ir_cron_demo.xml b/scheduler_error_mailer/ir_cron_demo.xml deleted file mode 100644 index 4c108040c..000000000 --- a/scheduler_error_mailer/ir_cron_demo.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - Test Scheduler Error Mailer - - - 1 - hours - -1 - - ir.cron - _test_scheduler_failure - - - - - diff --git a/scheduler_error_mailer/models/__init__.py b/scheduler_error_mailer/models/__init__.py new file mode 100644 index 000000000..91c8e5e18 --- /dev/null +++ b/scheduler_error_mailer/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2012-2013 Akretion Sébastien BEAU,David Beal,Alexis de Lattre +# © 2016 Sodexis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import ir_cron diff --git a/scheduler_error_mailer/models/ir_cron.py b/scheduler_error_mailer/models/ir_cron.py new file mode 100644 index 000000000..a6134be15 --- /dev/null +++ b/scheduler_error_mailer/models/ir_cron.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# © 2012-2013 Akretion Sébastien BEAU,David Beal,Alexis de Lattre +# © 2016 Sodexis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields, api, _ +from openerp.exceptions import UserError +import logging + + +_logger = logging.getLogger(__name__) + + +class IrCron(models.Model): + _inherit = "ir.cron" + + email_template_id = fields.Many2one( + comodel_name="mail.template", + string="Error E-mail Template", + help="Select the email template that will be sent when " + "this scheduler fails." + ) + + @api.model + def _handle_callback_exception( + self, model_name, method_name, args, job_id, job_exception): + res = super(IrCron, self)._handle_callback_exception( + model_name, method_name, args, job_id, job_exception) + + my_cron = self.browse(job_id) + + if my_cron.email_template_id: + # 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, + } + + _logger.debug( + "Sending scheduler error email with context=%s", context) + + self.env['mail.template'].browse( + my_cron.email_template_id.id + ).with_context(context).sudo().send_mail( + my_cron.id, force_send=True) + + return res + + @api.model + def _test_scheduler_failure(self): + """This function is used to test and debug this module""" + + raise UserError( + _("Task failure with UID = %d.") % self._uid) diff --git a/scheduler_error_mailer/views/ir_cron.xml b/scheduler_error_mailer/views/ir_cron.xml new file mode 100644 index 000000000..3ade1e1b8 --- /dev/null +++ b/scheduler_error_mailer/views/ir_cron.xml @@ -0,0 +1,22 @@ + + + + + + + ir.cron.error.mailer.form + ir.cron + + + + + + + + +