diff --git a/fetchmail_incoming_log/README.rst b/fetchmail_incoming_log/README.rst new file mode 100644 index 000000000..9119fc5f2 --- /dev/null +++ b/fetchmail_incoming_log/README.rst @@ -0,0 +1,80 @@ +====================== +Fetchmail Incoming Log +====================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |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/fetchmail_incoming_log + :alt: OCA/server-tools +.. |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-fetchmail_incoming_log + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/149/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to log into the server the basic information of emails +that have been fetched from the mail server, before they start to be processed. + +This allows for a better analysis of situations where emails are found to be +missing in Odoo. Can help to better resolve questions of the type 'Was it that +the email was never fetched, or a problem found when it was processed by +Odoo?'. + +**Table of contents** + +.. contents:: + :local: + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Eficent + +Contributors +~~~~~~~~~~~~ + +* Jordi Ballester +* Héctor Villarreal + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/server-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/fetchmail_incoming_log/__init__.py b/fetchmail_incoming_log/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/fetchmail_incoming_log/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/fetchmail_incoming_log/__manifest__.py b/fetchmail_incoming_log/__manifest__.py new file mode 100644 index 000000000..1e49e5884 --- /dev/null +++ b/fetchmail_incoming_log/__manifest__.py @@ -0,0 +1,17 @@ +# © 2017 Eficent Business and IT Consulting Services S.L. (www.eficent.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'Fetchmail Incoming Log', + 'version': '12.0.1.0.0', + 'category': 'Tools', + 'summary': 'Log all messages received, before they start to be processed.', + 'author': "Eficent, " + "Odoo Community Association (OCA)", + 'license': 'AGPL-3', + 'website': 'https://github.com/OCA/server-tools', + 'depends': [ + 'mail', 'test_mail', + ], + 'installable': True, +} diff --git a/fetchmail_incoming_log/i18n/ca.po b/fetchmail_incoming_log/i18n/ca.po new file mode 100644 index 000000000..12cc73d1e --- /dev/null +++ b/fetchmail_incoming_log/i18n/ca.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_log_messages_to_process +# +# Translators: +# Marc Tormo i Bochaca , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-10-21 22:54+0000\n" +"PO-Revision-Date: 2017-10-21 22:54+0000\n" +"Last-Translator: Marc Tormo i Bochaca , 2017\n" +"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: fetchmail_incoming_log +#: model:ir.model,name:fetchmail_incoming_log.model_mail_thread +msgid "Email Thread" +msgstr "Tema del Correu electrònic" diff --git a/fetchmail_incoming_log/i18n/de.po b/fetchmail_incoming_log/i18n/de.po new file mode 100644 index 000000000..795aa4768 --- /dev/null +++ b/fetchmail_incoming_log/i18n/de.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_log_messages_to_process +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-10-21 22:54+0000\n" +"PO-Revision-Date: 2017-10-21 22:54+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: fetchmail_incoming_log +#: model:ir.model,name:fetchmail_incoming_log.model_mail_thread +msgid "Email Thread" +msgstr "Email-Thread" diff --git a/fetchmail_incoming_log/i18n/es.po b/fetchmail_incoming_log/i18n/es.po new file mode 100644 index 000000000..7e4287a2a --- /dev/null +++ b/fetchmail_incoming_log/i18n/es.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_log_messages_to_process +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-10-21 22:54+0000\n" +"PO-Revision-Date: 2017-10-21 22:54+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: fetchmail_incoming_log +#: model:ir.model,name:fetchmail_incoming_log.model_mail_thread +msgid "Email Thread" +msgstr "Hilo correo electrónico" diff --git a/fetchmail_incoming_log/i18n/fetchmail_incoming_log.pot b/fetchmail_incoming_log/i18n/fetchmail_incoming_log.pot new file mode 100644 index 000000000..3027e92a9 --- /dev/null +++ b/fetchmail_incoming_log/i18n/fetchmail_incoming_log.pot @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fetchmail_incoming_log +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: fetchmail_incoming_log +#: model:ir.model,name:fetchmail_incoming_log.model_mail_thread +msgid "Email Thread" +msgstr "" + diff --git a/fetchmail_incoming_log/i18n/fr.po b/fetchmail_incoming_log/i18n/fr.po new file mode 100644 index 000000000..8e4774168 --- /dev/null +++ b/fetchmail_incoming_log/i18n/fr.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_log_messages_to_process +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-10-21 22:54+0000\n" +"PO-Revision-Date: 2017-10-21 22:54+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: fetchmail_incoming_log +#: model:ir.model,name:fetchmail_incoming_log.model_mail_thread +msgid "Email Thread" +msgstr "Discussion de courriel" diff --git a/fetchmail_incoming_log/i18n/it.po b/fetchmail_incoming_log/i18n/it.po new file mode 100644 index 000000000..8c8cfa8c4 --- /dev/null +++ b/fetchmail_incoming_log/i18n/it.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_log_messages_to_process +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-10-21 22:54+0000\n" +"PO-Revision-Date: 2017-10-21 22:54+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: fetchmail_incoming_log +#: model:ir.model,name:fetchmail_incoming_log.model_mail_thread +msgid "Email Thread" +msgstr "Discussione Email" diff --git a/fetchmail_incoming_log/i18n/mail_log_message_to_process.pot b/fetchmail_incoming_log/i18n/mail_log_message_to_process.pot new file mode 100644 index 000000000..8b75d5db4 --- /dev/null +++ b/fetchmail_incoming_log/i18n/mail_log_message_to_process.pot @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_log_message_to_process +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mail_log_message_to_process +#: model:ir.model,name:mail_log_message_to_process.model_mail_thread +msgid "Email Thread" +msgstr "" + diff --git a/fetchmail_incoming_log/i18n/pt_BR.po b/fetchmail_incoming_log/i18n/pt_BR.po new file mode 100644 index 000000000..668878c25 --- /dev/null +++ b/fetchmail_incoming_log/i18n/pt_BR.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_log_messages_to_process +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-10-21 22:54+0000\n" +"PO-Revision-Date: 2017-10-21 22:54+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: fetchmail_incoming_log +#: model:ir.model,name:fetchmail_incoming_log.model_mail_thread +msgid "Email Thread" +msgstr "Processo Email" diff --git a/fetchmail_incoming_log/i18n/pt_PT.po b/fetchmail_incoming_log/i18n/pt_PT.po new file mode 100644 index 000000000..b629eed23 --- /dev/null +++ b/fetchmail_incoming_log/i18n/pt_PT.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_log_messages_to_process +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-10-21 22:54+0000\n" +"PO-Revision-Date: 2017-10-21 22:54+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Portuguese (Portugal) (https://www.transifex.com/oca/" +"teams/23907/pt_PT/)\n" +"Language: pt_PT\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: fetchmail_incoming_log +#: model:ir.model,name:fetchmail_incoming_log.model_mail_thread +msgid "Email Thread" +msgstr "Tópico de Email" diff --git a/fetchmail_incoming_log/i18n/sl.po b/fetchmail_incoming_log/i18n/sl.po new file mode 100644 index 000000000..ef470961f --- /dev/null +++ b/fetchmail_incoming_log/i18n/sl.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_log_messages_to_process +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-10-21 22:54+0000\n" +"PO-Revision-Date: 2017-10-21 22:54+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \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_incoming_log +#: model:ir.model,name:fetchmail_incoming_log.model_mail_thread +msgid "Email Thread" +msgstr "E-poštna nit" diff --git a/fetchmail_incoming_log/i18n/tr.po b/fetchmail_incoming_log/i18n/tr.po new file mode 100644 index 000000000..0f5a6764c --- /dev/null +++ b/fetchmail_incoming_log/i18n/tr.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_log_messages_to_process +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-10-21 22:54+0000\n" +"PO-Revision-Date: 2017-10-21 22:54+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" +"Language: tr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: fetchmail_incoming_log +#: model:ir.model,name:fetchmail_incoming_log.model_mail_thread +msgid "Email Thread" +msgstr "Eposta konuşması" diff --git a/fetchmail_incoming_log/models/__init__.py b/fetchmail_incoming_log/models/__init__.py new file mode 100644 index 000000000..b70a9f2d0 --- /dev/null +++ b/fetchmail_incoming_log/models/__init__.py @@ -0,0 +1 @@ +from . import mail_thread diff --git a/fetchmail_incoming_log/models/mail_thread.py b/fetchmail_incoming_log/models/mail_thread.py new file mode 100644 index 000000000..7f218acb7 --- /dev/null +++ b/fetchmail_incoming_log/models/mail_thread.py @@ -0,0 +1,42 @@ +# Copyright 2017-18 Eficent Business and IT Consulting Services S.L. +# (www.eficent.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +import email +import xmlrpc.client as xmlrpclib +import logging +from odoo import api, models +from odoo.tools import pycompat + +_logger = logging.getLogger(__name__) + + +class MailThread(models.AbstractModel): + _inherit = 'mail.thread' + + @api.model + def message_process(self, model, message, custom_values=None, + save_original=False, strip_attachments=False, + thread_id=None): + + if isinstance(message, xmlrpclib.Binary): + message = bytes(message.data) + # message_from_string parses from a *native string*, except + # apparently sometimes message is ISO-8859-1 binary data or some + # shit and the straightforward version (pycompat.to_native) won't + # work right -> always encode message to bytes then use the + # relevant method depending on ~python version + if isinstance(message, pycompat.text_type): + message = message.encode('utf-8') + extract = getattr(email, 'message_from_bytes', + email.message_from_string) + msg_txt = extract(message) + msg = self.message_parse(msg_txt) + _logger.info( + 'Fetched mail from %s to %s with Message-Id %s', + msg.get('from'), msg.get('to'), msg.get('message_id')) + + return super(MailThread, self).message_process( + model, message, custom_values=custom_values, + save_original=save_original, + strip_attachments=strip_attachments, thread_id=thread_id) diff --git a/fetchmail_incoming_log/readme/CONTRIBUTORS.rst b/fetchmail_incoming_log/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..900b15109 --- /dev/null +++ b/fetchmail_incoming_log/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Jordi Ballester +* Héctor Villarreal diff --git a/fetchmail_incoming_log/readme/DESCRIPTION.rst b/fetchmail_incoming_log/readme/DESCRIPTION.rst new file mode 100644 index 000000000..53be783f1 --- /dev/null +++ b/fetchmail_incoming_log/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +This module allows to log into the server the basic information of emails +that have been fetched from the mail server, before they start to be processed. + +This allows for a better analysis of situations where emails are found to be +missing in Odoo. Can help to better resolve questions of the type 'Was it that +the email was never fetched, or a problem found when it was processed by +Odoo?'. diff --git a/fetchmail_incoming_log/static/description/icon.png b/fetchmail_incoming_log/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/fetchmail_incoming_log/static/description/icon.png differ diff --git a/fetchmail_incoming_log/static/description/index.html b/fetchmail_incoming_log/static/description/index.html new file mode 100644 index 000000000..270192cd7 --- /dev/null +++ b/fetchmail_incoming_log/static/description/index.html @@ -0,0 +1,425 @@ + + + + + + +Fetchmail Incoming Log + + + +
+

Fetchmail Incoming Log

+ + +

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

+

This module allows to log into the server the basic information of emails +that have been fetched from the mail server, before they start to be processed.

+

This allows for a better analysis of situations where emails are found to be +missing in Odoo. Can help to better resolve questions of the type ‘Was it that +the email was never fetched, or a problem found when it was processed by +Odoo?’.

+

Table of contents

+ +
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Eficent
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/server-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/fetchmail_incoming_log/tests/__init__.py b/fetchmail_incoming_log/tests/__init__.py new file mode 100644 index 000000000..85aed3ed2 --- /dev/null +++ b/fetchmail_incoming_log/tests/__init__.py @@ -0,0 +1 @@ +from . import test_fetchmail_incoming_log diff --git a/fetchmail_incoming_log/tests/test_fetchmail_incoming_log.py b/fetchmail_incoming_log/tests/test_fetchmail_incoming_log.py new file mode 100644 index 000000000..08c9c22b8 --- /dev/null +++ b/fetchmail_incoming_log/tests/test_fetchmail_incoming_log.py @@ -0,0 +1,35 @@ +# Copyright 2017-18 Eficent Business and IT Consulting Services S.L. +# (www.eficent.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo.addons.test_mail.tests.test_mail_gateway import TestMailgateway +from odoo.addons.test_mail.data.test_mail_data import MAIL_TEMPLATE + + +class TestFetchmailIncomingLog(TestMailgateway): + + def setUp(self): + super(TestFetchmailIncomingLog, self).setUp() + + self.fetchmail_server = self.env['fetchmail.server'].create({ + 'name': 'Test Fetchmail Server', + 'type': 'imap', + }) + + def test_message_process(self): + email_from = 'test1@example.com' + to_email = 'test2@example.com' + msg_id = 'Test log message to process' + with self.assertRaises(ValueError): + mail = MAIL_TEMPLATE.format( + to=to_email, + email_from=email_from, + cc='', + subject='testing', + extra='', + msg_id=msg_id, + ) + self.env['mail.thread'].with_context({ + 'fetchmail_server_id': self.fetchmail_server.id, + }).message_process(None, mail)