From 637049ed27e108da8607b507d25e12f4a219779e Mon Sep 17 00:00:00 2001
From: mreficent
Date: Tue, 21 Apr 2020 17:37:46 +0200
Subject: [PATCH] [MIG] fetchmail_incoming_log: Migration to 13.0
---
fetchmail_incoming_log/README.rst | 18 ++++++-------
fetchmail_incoming_log/__manifest__.py | 8 +++---
.../i18n/fetchmail_incoming_log.pot | 2 +-
.../i18n/mail_log_message_to_process.pot | 20 --------------
fetchmail_incoming_log/models/mail_thread.py | 26 +++++++------------
.../readme/CONTRIBUTORS.rst | 4 +--
.../static/description/index.html | 12 ++++-----
.../tests/test_fetchmail_incoming_log.py | 17 +++++++-----
8 files changed, 41 insertions(+), 66 deletions(-)
delete mode 100644 fetchmail_incoming_log/i18n/mail_log_message_to_process.pot
diff --git a/fetchmail_incoming_log/README.rst b/fetchmail_incoming_log/README.rst
index 9119fc5f2..91173b1cf 100644
--- a/fetchmail_incoming_log/README.rst
+++ b/fetchmail_incoming_log/README.rst
@@ -14,16 +14,16 @@ Fetchmail Incoming Log
: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
+ :target: https://github.com/OCA/server-tools/tree/13.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
+ :target: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-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
+ :target: https://runbot.odoo-community.org/runbot/149/13.0
:alt: Try me on Runbot
-|badge1| |badge2| |badge3| |badge4| |badge5|
+|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.
@@ -44,7 +44,7 @@ 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -54,13 +54,13 @@ Credits
Authors
~~~~~~~
-* Eficent
+* ForgeFlow
Contributors
~~~~~~~~~~~~
-* Jordi Ballester
-* Héctor Villarreal
+* Jordi Ballester
+* Héctor Villarreal
Maintainers
~~~~~~~~~~~
@@ -75,6 +75,6 @@ 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.
+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/__manifest__.py b/fetchmail_incoming_log/__manifest__.py
index 374b0dd75..d2c7b0fd2 100644
--- a/fetchmail_incoming_log/__manifest__.py
+++ b/fetchmail_incoming_log/__manifest__.py
@@ -1,14 +1,14 @@
-# © 2017 Eficent Business and IT Consulting Services S.L. (www.eficent.com)
+# Copyright 2017-20 ForgeFlow S.L. (www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Fetchmail Incoming Log",
- "version": "12.0.1.0.0",
+ "version": "13.0.1.0.0",
"category": "Tools",
"summary": "Log all messages received, before they start to be processed.",
- "author": "Eficent, " "Odoo Community Association (OCA)",
+ "author": "ForgeFlow, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/server-tools",
- "depends": ["mail", "test_mail",],
+ "depends": ["mail", "test_mail"],
"installable": True,
}
diff --git a/fetchmail_incoming_log/i18n/fetchmail_incoming_log.pot b/fetchmail_incoming_log/i18n/fetchmail_incoming_log.pot
index b5ea2b952..42ab3e27c 100644
--- a/fetchmail_incoming_log/i18n/fetchmail_incoming_log.pot
+++ b/fetchmail_incoming_log/i18n/fetchmail_incoming_log.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 12.0\n"
+"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
diff --git a/fetchmail_incoming_log/i18n/mail_log_message_to_process.pot b/fetchmail_incoming_log/i18n/mail_log_message_to_process.pot
deleted file mode 100644
index 8b75d5db4..000000000
--- a/fetchmail_incoming_log/i18n/mail_log_message_to_process.pot
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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/models/mail_thread.py b/fetchmail_incoming_log/models/mail_thread.py
index 9d77f6c2e..88af8bc7d 100644
--- a/fetchmail_incoming_log/models/mail_thread.py
+++ b/fetchmail_incoming_log/models/mail_thread.py
@@ -1,5 +1,4 @@
-# Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
-# (www.eficent.com)
+# Copyright 2017-20 ForgeFlow S.L. (www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import email
@@ -7,7 +6,6 @@ import logging
import xmlrpc.client as xmlrpclib
from odoo import api, models
-from odoo.tools import pycompat
_logger = logging.getLogger(__name__)
@@ -25,29 +23,23 @@ class MailThread(models.AbstractModel):
strip_attachments=False,
thread_id=None,
):
-
+ message_copy = message
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):
+ if isinstance(message, str):
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)
+ message = email.message_from_bytes(message)
+ msg_dict = self.message_parse(message, save_original=save_original)
_logger.info(
"Fetched mail from %s to %s with Message-Id %s",
- msg.get("from"),
- msg.get("to"),
- msg.get("message_id"),
+ msg_dict.get("from"),
+ msg_dict.get("to"),
+ msg_dict.get("message_id"),
)
return super(MailThread, self).message_process(
model,
- message,
+ message_copy,
custom_values=custom_values,
save_original=save_original,
strip_attachments=strip_attachments,
diff --git a/fetchmail_incoming_log/readme/CONTRIBUTORS.rst b/fetchmail_incoming_log/readme/CONTRIBUTORS.rst
index 900b15109..1f463e7a5 100644
--- a/fetchmail_incoming_log/readme/CONTRIBUTORS.rst
+++ b/fetchmail_incoming_log/readme/CONTRIBUTORS.rst
@@ -1,2 +1,2 @@
-* Jordi Ballester
-* Héctor Villarreal
+* Jordi Ballester
+* Héctor Villarreal
diff --git a/fetchmail_incoming_log/static/description/index.html b/fetchmail_incoming_log/static/description/index.html
index 788d8dabd..ffb61de89 100644
--- a/fetchmail_incoming_log/static/description/index.html
+++ b/fetchmail_incoming_log/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

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
@@ -391,7 +391,7 @@ Odoo?’.
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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -399,14 +399,14 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
@@ -416,7 +416,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
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.
+
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/test_fetchmail_incoming_log.py b/fetchmail_incoming_log/tests/test_fetchmail_incoming_log.py
index c3ab8c73f..3d57c3650 100644
--- a/fetchmail_incoming_log/tests/test_fetchmail_incoming_log.py
+++ b/fetchmail_incoming_log/tests/test_fetchmail_incoming_log.py
@@ -1,18 +1,21 @@
-# Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
-# (www.eficent.com)
+# Copyright 2017-20 ForgeFlow S.L. (www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+from odoo.tests.common import tagged
+
from odoo.addons.test_mail.data.test_mail_data import MAIL_TEMPLATE
from odoo.addons.test_mail.tests.test_mail_gateway import TestMailgateway
+@tagged("mail_gateway")
class TestFetchmailIncomingLog(TestMailgateway):
- def setUp(self):
- super(TestFetchmailIncomingLog, self).setUp()
+ @classmethod
+ def setUpClass(cls):
+ super(TestFetchmailIncomingLog, cls).setUpClass()
- self.fetchmail_server = self.env["fetchmail.server"].create(
- {"name": "Test Fetchmail Server", "type": "imap",}
+ cls.fetchmail_server = cls.env["fetchmail.server"].create(
+ {"name": "Test Fetchmail Server", "server_type": "imap"}
)
def test_message_process(self):
@@ -29,5 +32,5 @@ class TestFetchmailIncomingLog(TestMailgateway):
msg_id=msg_id,
)
self.env["mail.thread"].with_context(
- {"fetchmail_server_id": self.fetchmail_server.id,}
+ {"fetchmail_server_id": self.fetchmail_server.id}
).message_process(None, mail)