[MIG] scheduler_error_mailer: Migration to 13.0

TT27587
pull/2794/head
Achraf Mhadhbi 2020-02-26 21:35:39 +01:00 committed by Cuong, Nguyen Minh Tran Manh
parent 4f3af43662
commit 4279550c26
7 changed files with 18 additions and 51 deletions

View File

@ -14,13 +14,13 @@ Scheduler Error Mailer
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/12.0/scheduler_error_mailer :target: https://github.com/OCA/server-tools/tree/13.0/scheduler_error_mailer
:alt: OCA/server-tools :alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-scheduler_error_mailer :target: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-scheduler_error_mailer
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/149/12.0 :target: https://runbot.odoo-community.org/runbot/149/13.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -47,7 +47,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20scheduler_error_mailer%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20scheduler_error_mailer%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -72,6 +72,7 @@ Contributors
* `Tecnativa <https://www.tecnativa.com>`_: * `Tecnativa <https://www.tecnativa.com>`_:
* Cristina Martin R. * Cristina Martin R.
* Víctor Martínez
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@ -86,6 +87,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/12.0/scheduler_error_mailer>`_ project on GitHub. This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/13.0/scheduler_error_mailer>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -6,13 +6,13 @@
{ {
"name": "Scheduler Error Mailer", "name": "Scheduler Error Mailer",
"version": "12.0.1.2.0", "version": "13.0.1.0.0",
"category": "Extra Tools", "category": "Extra Tools",
"license": "AGPL-3", "license": "AGPL-3",
"author": "Akretion,Sodexis,Odoo Community Association (OCA)", "author": "Akretion,Sodexis,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-tools", "website": "https://github.com/OCA/server-tools",
"depends": ["mail"], "depends": ["mail"],
"data": ["data/ir_cron_email_tpl.xml", "views/ir_cron.xml",], "data": ["data/ir_cron_email_tpl.xml", "views/ir_cron.xml"],
"demo": ["demo/ir_cron_demo.xml"], "demo": ["demo/ir_cron_demo.xml"],
"images": ["images/scheduler_error_mailer.jpg"], "images": ["images/scheduler_error_mailer.jpg"],
"installable": True, "installable": True,

View File

@ -1,13 +0,0 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
template = env.ref("scheduler_error_mailer.scheduler_error_mailer")
template.body_html = template.body_html.replace(
"${ctx.get('job_exception') and ctx.get('job_exception').value",
"${ctx.get('job_exception')",
)

View File

@ -1,19 +0,0 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
template = env.ref("scheduler_error_mailer.scheduler_error_mailer")
template.body_html = template.body_html.replace(
"${object.model or ''}", "${object.model_id.name or ''}"
)
template.body_html = template.body_html.replace(
"<li>Method : ${object.function or ''}</li>", ""
)
template.body_html = template.body_html.replace(
"<li>Arguments : ${object.args or ''}</li>",
"<li>Python code : <code>${object.code or ''}</code></li>",
)

View File

@ -25,7 +25,7 @@ class IrCron(models.Model):
def _handle_callback_exception( def _handle_callback_exception(
self, cron_name, server_action_id, job_id, job_exception self, cron_name, server_action_id, job_id, job_exception
): ):
res = super(IrCron, self)._handle_callback_exception( res = super()._handle_callback_exception(
cron_name, server_action_id, job_id, job_exception cron_name, server_action_id, job_id, job_exception
) )
my_cron = self.browse(job_id) my_cron = self.browse(job_id)
@ -33,16 +33,12 @@ class IrCron(models.Model):
if my_cron.email_template_id: if my_cron.email_template_id:
# 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 = { context = {"job_exception": str(job_exception), "dbname": self._cr.dbname}
"job_exception": str(job_exception),
"dbname": self._cr.dbname,
}
_logger.debug("Sending scheduler error email with context=%s", context) _logger.debug("Sending scheduler error email with context=%s", context)
self.env["mail.template"].browse(my_cron.email_template_id.id).with_context( template = my_cron.email_template_id.with_context(context).sudo()
context template.send_mail(my_cron.id, force_send=True)
).sudo().send_mail(my_cron.id, force_send=True)
return res return res

View File

@ -7,3 +7,4 @@
* `Tecnativa <https://www.tecnativa.com>`_: * `Tecnativa <https://www.tecnativa.com>`_:
* Cristina Martin R. * Cristina Martin R.
* Víctor Martínez

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Scheduler Error Mailer</title> <title>Scheduler Error Mailer</title>
<style type="text/css"> <style type="text/css">
@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/12.0/scheduler_error_mailer"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-scheduler_error_mailer"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/13.0/scheduler_error_mailer"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-scheduler_error_mailer"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds the possibility to send an e-mail when a scheduler raises <p>This module adds the possibility to send an e-mail when a scheduler raises
an error.</p> an error.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
@ -396,7 +396,7 @@ an error.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20scheduler_error_mailer%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20scheduler_error_mailer%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -418,6 +418,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Achraf Mhadhbi &lt;<a class="reference external" href="mailto:machraf&#64;bloopark.de">machraf&#64;bloopark.de</a>&gt;</li> <li>Achraf Mhadhbi &lt;<a class="reference external" href="mailto:machraf&#64;bloopark.de">machraf&#64;bloopark.de</a>&gt;</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul> <li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Cristina Martin R.</li> <li>Cristina Martin R.</li>
<li>Víctor Martínez</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -429,7 +430,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/12.0/scheduler_error_mailer">OCA/server-tools</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/13.0/scheduler_error_mailer">OCA/server-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>