[MIG] fetchmail_notify_error_to_sender
parent
0a940ea1df
commit
ed24d7fd56
|
@ -1,38 +1,63 @@
|
||||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||||
:alt: License: AGPL-3
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
|
:alt: License: AGPL-3
|
||||||
|
|
||||||
|
===============================
|
||||||
Send notice on fetchmail errors
|
Send notice on fetchmail errors
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
If fetchmail is not able to correctly route an email, the email is "silently" lost (you get an error message in server log).
|
If fetchmail is not able to correctly route an email, the email is
|
||||||
For example, if you configure odoo mail system to route received emails according to recipient address, it may happen users send emails to wrong email address.
|
"silently" lost (you get an error message in server log).
|
||||||
|
|
||||||
This module allows to automatically send a notification email to sender, when odoo can't correctly process the received email.
|
For example, if you configure odoo mail system to route received emails
|
||||||
|
according to recipient address, it may happen users send emails to wrong
|
||||||
|
email address.
|
||||||
|
|
||||||
|
This module extends the functionality of fetchmail to allow you to
|
||||||
|
automatically send a notification email to sender, when odoo can't
|
||||||
|
correctly process the received email.
|
||||||
|
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
=============
|
=============
|
||||||
|
|
||||||
Configure your fetchmail server setting 'Error notice template' = 'Fetchmail - error notice'.
|
To configure this module, you need to:
|
||||||
You can edit the 'Fetchmail - error notice' email template according to your needs.
|
|
||||||
|
|
||||||
|
#. Configure your fetchmail server setting 'Error notice template' = 'Fetchmail - error notice'.
|
||||||
|
#. You can edit the 'Fetchmail - error notice' email template according to your needs.
|
||||||
|
|
||||||
|
.. figure:: path/to/local/image.png
|
||||||
|
:alt: alternative description
|
||||||
|
:width: 600 px
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
.. 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
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
|
Bugs are tracked on `GitHub Issues
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
<https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
|
check there if your issue has already been reported. If you spotted it first,
|
||||||
`here <https://github.com/OCA/server-tools/issues/new?body=module:%20fetchmail_notify_error_to_sender%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
help us smash it by providing detailed and welcomed feedback.
|
||||||
|
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
Images
|
||||||
|
------
|
||||||
|
|
||||||
|
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||||
|
|
||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
|
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
|
||||||
|
* Miquel Raïch <miquel.raich@eficent.com> (migration to v9)
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
@ -47,4 +72,4 @@ 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.
|
||||||
|
|
||||||
To contribute to this module, please visit http://odoo-community.org.
|
To contribute to this module, please visit https://odoo-community.org.
|
|
@ -1,22 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# Copyright 2015 Lorenzo Battistini <lorenzo.battistini@agilebg.com>
|
||||||
#
|
# Copyright 2017 Eficent <http://www.eficent.com>
|
||||||
# Copyright (C) 2015 Lorenzo Battistini <lorenzo.battistini@agilebg.com>
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
#
|
|
||||||
# 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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
from . import mail_thread
|
from . import models
|
||||||
from . import fetchmail
|
|
||||||
|
|
|
@ -1,40 +1,25 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# Copyright 2015 Lorenzo Battistini <lorenzo.battistini@agilebg.com>
|
||||||
#
|
# Copyright 2017 Eficent <http://www.eficent.com>
|
||||||
# Copyright (C) 2015 Lorenzo Battistini <lorenzo.battistini@agilebg.com>
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
#
|
|
||||||
# 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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Send notice on fetchmail errors',
|
'name': 'Send notice on fetchmail errors',
|
||||||
'summary': 'If fetching mails gives error, send an email to sender',
|
'summary': 'If fetching mails gives error, send an email to sender',
|
||||||
'version': '8.0.1.0.1',
|
'version': '9.0.1.0.0',
|
||||||
'category': 'Tools',
|
'category': 'Tools',
|
||||||
'author': "Agile Business Group,Odoo Community Association (OCA)",
|
'author': "Agile Business Group,Eficent,Odoo Community Association (OCA)",
|
||||||
'website': 'http://www.agilebg.com',
|
'website': 'https://github.com/OCA/server-tools',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'depends': [
|
'depends': [
|
||||||
'fetchmail',
|
'fetchmail',
|
||||||
],
|
],
|
||||||
'data': [
|
'data': [
|
||||||
'fetchmail_view.xml',
|
'views/fetchmail_view.xml',
|
||||||
'email_template_data.xml',
|
'data/email_template_data.xml',
|
||||||
],
|
],
|
||||||
'qweb': [
|
'qweb': [
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'auto_install': False,
|
'application': False,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" ?>
|
||||||
<openerp>
|
<openerp>
|
||||||
|
|
||||||
<data noupdate="1">
|
<data noupdate="1">
|
||||||
<!--Email template -->
|
<!--Email template -->
|
||||||
<record id="email_template_error_notice" model="email.template">
|
<record id="email_template_error_notice" model="mail.template">
|
||||||
<field name="name">Fetchmail - error notice</field>
|
<field name="name">Fetchmail - error notice</field>
|
||||||
<field name="email_from">${ctx.get('sender_message').get('to')|safe}</field>
|
<field name="email_from">${ctx.get('sender_message').get('to')|safe}</field>
|
||||||
<field name="email_to">${ctx.get('sender_message').get('from')|safe}</field>
|
<field name="email_to">${ctx.get('sender_message').get('from')|safe}</field>
|
|
@ -1,30 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# Copyright (C) 2015 Lorenzo Battistini <lorenzo.battistini@agilebg.com>
|
|
||||||
#
|
|
||||||
# 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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
from openerp import models, fields
|
|
||||||
|
|
||||||
|
|
||||||
class fetchmail_server(models.Model):
|
|
||||||
|
|
||||||
_inherit = 'fetchmail.server'
|
|
||||||
error_notice_template_id = fields.Many2one(
|
|
||||||
'email.template', string="Error notice template",
|
|
||||||
help="Set here the template to use to send notice to sender when "
|
|
||||||
"errors occur while fetching email")
|
|
|
@ -19,7 +19,7 @@ msgstr ""
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid ""
|
msgid ""
|
||||||
"\n"
|
"\n"
|
||||||
"<div>\n"
|
"<div>\n"
|
||||||
|
@ -49,7 +49,7 @@ msgid "POP/IMAP Server"
|
||||||
msgstr "POP/IMAP Server"
|
msgstr "POP/IMAP Server"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
msgstr "Erhalte Fehler mit: ${ctx.get('sender_message').get('subject')|safe}"
|
msgstr "Erhalte Fehler mit: ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ msgstr ""
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid ""
|
msgid ""
|
||||||
"\n"
|
"\n"
|
||||||
"<div>\n"
|
"<div>\n"
|
||||||
|
@ -78,7 +78,7 @@ msgid "POP/IMAP Server"
|
||||||
msgstr "Servidor POP/IMAP"
|
msgstr "Servidor POP/IMAP"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ msgstr ""
|
||||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid ""
|
msgid ""
|
||||||
"\n"
|
"\n"
|
||||||
"<div>\n"
|
"<div>\n"
|
||||||
|
@ -79,7 +79,7 @@ msgid "POP/IMAP Server"
|
||||||
msgstr "Serveur POP/IMAP"
|
msgstr "Serveur POP/IMAP"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
msgstr "Reçu une erreur avec : ${ctx.get('sender_message').get('subject')|safe}"
|
msgstr "Reçu une erreur avec : ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ msgstr ""
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid ""
|
msgid ""
|
||||||
"\n"
|
"\n"
|
||||||
"<div>\n"
|
"<div>\n"
|
||||||
|
@ -57,7 +57,7 @@ msgid "POP/IMAP Server"
|
||||||
msgstr "Server POP/IMAP"
|
msgstr "Server POP/IMAP"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ msgstr ""
|
||||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid ""
|
msgid ""
|
||||||
"\n"
|
"\n"
|
||||||
"<div>\n"
|
"<div>\n"
|
||||||
|
@ -49,7 +49,7 @@ msgid "POP/IMAP Server"
|
||||||
msgstr "Servidor POP/IMAP"
|
msgstr "Servidor POP/IMAP"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
msgstr "Recebendo erro com: ${ctx.get('sender_message').get('subject')|safe}"
|
msgstr "Recebendo erro com: ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ msgstr ""
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid ""
|
msgid ""
|
||||||
"\n"
|
"\n"
|
||||||
"<div>\n"
|
"<div>\n"
|
||||||
|
@ -48,7 +48,7 @@ msgid "POP/IMAP Server"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ msgstr ""
|
||||||
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
|
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid ""
|
msgid ""
|
||||||
"\n"
|
"\n"
|
||||||
"<div>\n"
|
"<div>\n"
|
||||||
|
@ -49,7 +49,7 @@ msgid "POP/IMAP Server"
|
||||||
msgstr "POP/IMAP strežnik"
|
msgstr "POP/IMAP strežnik"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
msgstr "Napaka pri prejemu: ${ctx.get('sender_message').get('subject')|safe}"
|
msgstr "Napaka pri prejemu: ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ msgstr ""
|
||||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,body_html:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid ""
|
msgid ""
|
||||||
"\n"
|
"\n"
|
||||||
"<div>\n"
|
"<div>\n"
|
||||||
|
@ -49,7 +49,7 @@ msgid "POP/IMAP Server"
|
||||||
msgstr "POP/IMAP sunucu"
|
msgstr "POP/IMAP sunucu"
|
||||||
|
|
||||||
#. module: fetchmail_notify_error_to_sender
|
#. module: fetchmail_notify_error_to_sender
|
||||||
#: model:email.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
#: model:mail.template,subject:fetchmail_notify_error_to_sender.email_template_error_notice
|
||||||
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
msgid "Receiving error with: ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
msgstr "Alınan hata : ${ctx.get('sender_message').get('subject')|safe}"
|
msgstr "Alınan hata : ${ctx.get('sender_message').get('subject')|safe}"
|
||||||
|
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# Copyright (C) 2015 Lorenzo Battistini <lorenzo.battistini@agilebg.com>
|
|
||||||
#
|
|
||||||
# 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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
from openerp.osv import osv
|
|
||||||
|
|
||||||
|
|
||||||
class mail_thread(osv.AbstractModel):
|
|
||||||
_inherit = 'mail.thread'
|
|
||||||
|
|
||||||
def message_route_verify(
|
|
||||||
self, cr, uid, message, message_dict, route, update_author=True,
|
|
||||||
assert_model=True, create_fallback=True, allow_private=False,
|
|
||||||
context=None
|
|
||||||
):
|
|
||||||
res = ()
|
|
||||||
if context is None:
|
|
||||||
context = {}
|
|
||||||
try:
|
|
||||||
res = super(mail_thread, self).message_route_verify(
|
|
||||||
cr, uid, message, message_dict, route,
|
|
||||||
update_author=update_author, assert_model=assert_model,
|
|
||||||
create_fallback=create_fallback, allow_private=allow_private,
|
|
||||||
context=context)
|
|
||||||
except ValueError as ve:
|
|
||||||
fetchmail_server_id = context.get('fetchmail_server_id')
|
|
||||||
if not fetchmail_server_id:
|
|
||||||
raise ve
|
|
||||||
fetchmail_server = self.pool['fetchmail.server'].browse(
|
|
||||||
cr, uid, fetchmail_server_id, context)
|
|
||||||
if not fetchmail_server.error_notice_template_id:
|
|
||||||
raise ve
|
|
||||||
context['sender_message'] = message
|
|
||||||
context['route_exception'] = ve
|
|
||||||
self.pool['email.template'].send_mail(
|
|
||||||
cr, uid, fetchmail_server.error_notice_template_id.id,
|
|
||||||
fetchmail_server.id, context=context)
|
|
||||||
context['error_notice_sent'] = True
|
|
||||||
return res
|
|
||||||
|
|
||||||
def message_route(
|
|
||||||
self, cr, uid, message, message_dict, model=None, thread_id=None,
|
|
||||||
custom_values=None, context=None
|
|
||||||
):
|
|
||||||
if context is None:
|
|
||||||
context = {}
|
|
||||||
res = []
|
|
||||||
try:
|
|
||||||
res = super(mail_thread, self).message_route(
|
|
||||||
cr, uid, message, message_dict, model=model,
|
|
||||||
thread_id=thread_id, custom_values=custom_values,
|
|
||||||
context=context)
|
|
||||||
except ValueError as ve:
|
|
||||||
if context.get('error_notice_sent'):
|
|
||||||
# avoid raising exception and setting mail message UNSEEN
|
|
||||||
return []
|
|
||||||
else:
|
|
||||||
raise ve
|
|
||||||
return res
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2017 Eficent <http://www.eficent.com>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from . import fetchmail
|
||||||
|
from . import mail_thread
|
|
@ -0,0 +1,15 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2015 Lorenzo Battistini <lorenzo.battistini@agilebg.com>
|
||||||
|
# Copyright 2017 Eficent <http://www.eficent.com>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from openerp import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class FetchmailServer(models.Model):
|
||||||
|
|
||||||
|
_inherit = 'fetchmail.server'
|
||||||
|
error_notice_template_id = fields.Many2one(
|
||||||
|
'mail.template', string="Error notice template",
|
||||||
|
help="Set here the template to use to send notice to sender when "
|
||||||
|
"errors occur while fetching email")
|
|
@ -0,0 +1,53 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2015 Lorenzo Battistini <lorenzo.battistini@agilebg.com>
|
||||||
|
# Copyright 2017 Eficent <http://www.eficent.com>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from openerp import api, models
|
||||||
|
|
||||||
|
|
||||||
|
class MailThread(models.AbstractModel):
|
||||||
|
_inherit = 'mail.thread'
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def message_route_verify(
|
||||||
|
self, message, message_dict, route, update_author=True,
|
||||||
|
assert_model=True, create_fallback=True, allow_private=False):
|
||||||
|
res = ()
|
||||||
|
try:
|
||||||
|
res = super(MailThread, self).message_route_verify(
|
||||||
|
message, message_dict, route,
|
||||||
|
update_author=update_author, assert_model=assert_model,
|
||||||
|
create_fallback=create_fallback, allow_private=allow_private)
|
||||||
|
except ValueError as ve:
|
||||||
|
fetchmail_server_id = self.env.context.get('fetchmail_server_id')
|
||||||
|
if not fetchmail_server_id:
|
||||||
|
raise ve
|
||||||
|
fetchmail_server = self.pool['fetchmail.server'].browse(
|
||||||
|
fetchmail_server_id)
|
||||||
|
if not fetchmail_server.error_notice_template_id:
|
||||||
|
raise ve
|
||||||
|
self.env.context['sender_message'] = message
|
||||||
|
self.env.context['route_exception'] = ve
|
||||||
|
self.env['mail.template'].send_mail(
|
||||||
|
fetchmail_server.error_notice_template_id.id,
|
||||||
|
fetchmail_server.id)
|
||||||
|
self.env.context['error_notice_sent'] = True
|
||||||
|
return res
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def message_route(
|
||||||
|
self, message, message_dict, model=None, thread_id=None,
|
||||||
|
custom_values=None):
|
||||||
|
res = []
|
||||||
|
try:
|
||||||
|
res = super(MailThread, self).message_route(
|
||||||
|
message, message_dict, model=model,
|
||||||
|
thread_id=thread_id, custom_values=custom_values)
|
||||||
|
except ValueError as ve:
|
||||||
|
if self.env.context.get('error_notice_sent'):
|
||||||
|
# avoid raising exception and setting mail message UNSEEN
|
||||||
|
return []
|
||||||
|
else:
|
||||||
|
raise ve
|
||||||
|
return res
|
|
@ -1,16 +1,13 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<openerp>
|
<odoo>
|
||||||
<data>
|
|
||||||
|
|
||||||
<record model="ir.ui.view" id="view_email_server_form">
|
<record model="ir.ui.view" id="view_email_server_form">
|
||||||
<field name="name">fetchmail.server.form</field>
|
<field name="name">fetchmail.server.form</field>
|
||||||
<field name="model">fetchmail.server</field>
|
<field name="model">fetchmail.server</field>
|
||||||
<field name="inherit_id" ref="fetchmail.view_email_server_form"></field>
|
<field name="inherit_id" ref="fetchmail.view_email_server_form"></field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//page[@string='Advanced']/group/field[@name='active']" position="after">
|
<field name="active" position="after">
|
||||||
<field name="error_notice_template_id"/>
|
<field name="error_notice_template_id"/>
|
||||||
</xpath>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</odoo>
|
||||||
</openerp>
|
|
Loading…
Reference in New Issue