From add4bd178c3d565e61ff085e907ffdc122374b18 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 3 Dec 2018 11:53:45 +0100 Subject: [PATCH] [MIG] fetch_thread_default: Migration to 11.0 --- fetchmail_thread_default/README.rst | 74 ++++++++++++------- fetchmail_thread_default/__init__.py | 4 - .../{__openerp__.py => __manifest__.py} | 7 +- fetchmail_thread_default/demo/data.xml | 2 +- fetchmail_thread_default/models/__init__.py | 4 - .../models/fetchmail_server.py | 20 ++--- .../models/mail_thread.py | 5 +- fetchmail_thread_default/readme/CONFIGURE.rst | 9 +++ .../readme/CONTRIBUTORS.rst | 4 + .../readme/DESCRIPTION.rst | 16 ++++ fetchmail_thread_default/readme/USAGE.rst | 5 ++ fetchmail_thread_default/tests/__init__.py | 4 - .../tests/test_fetchmail.py | 18 ++--- .../views/fetchmail_server_view.xml | 2 +- 14 files changed, 103 insertions(+), 71 deletions(-) rename fetchmail_thread_default/{__openerp__.py => __manifest__.py} (76%) create mode 100644 fetchmail_thread_default/readme/CONFIGURE.rst create mode 100644 fetchmail_thread_default/readme/CONTRIBUTORS.rst create mode 100644 fetchmail_thread_default/readme/DESCRIPTION.rst create mode 100644 fetchmail_thread_default/readme/USAGE.rst diff --git a/fetchmail_thread_default/README.rst b/fetchmail_thread_default/README.rst index df2da8f2..d8892d2e 100644 --- a/fetchmail_thread_default/README.rst +++ b/fetchmail_thread_default/README.rst @@ -1,11 +1,30 @@ -.. 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 - =================================== Default Thread For Unbounded Emails =================================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fsocial-lightgray.png?logo=github + :target: https://github.com/OCA/social/tree/11.0/fetchmail_thread_default + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-11-0/social-11-0-fetchmail_thread_default + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/205/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + This module extends the functionality of mail fetching to support choosing a mail thread that acts as a mail sink and gathers all mail messages that Odoo does not know where to put. @@ -23,6 +42,11 @@ Here we come to the rescue. This simple addons adds almost none dependencies and allows you to direct those mails somewhere you can handle or ignore at wish. +**Table of contents** + +.. contents:: + :local: + Configuration ============= @@ -45,49 +69,45 @@ To use this module, you need to: #. You will be notified when a new unbound email lands in that thread. #. Do what you want with it. -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/205/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 smash it by providing detailed and welcomed feedback. +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 ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* Tecnativa Contributors ------------- +~~~~~~~~~~~~ -* Jairo Llopis +* `Tecnativa `_: -Funders -------- + * Jairo Llopis + * David Vidal -The development of this module has been financially supported by: +Maintainers +~~~~~~~~~~~ -* `Tecnativa `_. - -Maintainer ----------- +This module is maintained by the OCA. .. 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. +This module is part of the `OCA/social `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/fetchmail_thread_default/__init__.py b/fetchmail_thread_default/__init__.py index 1ed5d56b..0650744f 100644 --- a/fetchmail_thread_default/__init__.py +++ b/fetchmail_thread_default/__init__.py @@ -1,5 +1 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Jairo Llopis -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from . import models diff --git a/fetchmail_thread_default/__openerp__.py b/fetchmail_thread_default/__manifest__.py similarity index 76% rename from fetchmail_thread_default/__openerp__.py rename to fetchmail_thread_default/__manifest__.py index f78572a9..d569aa1e 100644 --- a/fetchmail_thread_default/__openerp__.py +++ b/fetchmail_thread_default/__manifest__.py @@ -1,12 +1,11 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Jairo Llopis +# Copyright 2017 Tecnativa - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Default Thread For Unbounded Emails", "summary": "Post unkonwn messages to an existing thread", - "version": "9.0.1.0.0", + "version": "11.0.1.0.0", "category": "Discuss", - "website": "https://www.tecnativa.com/", + "website": "https://www.github.com/social", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, diff --git a/fetchmail_thread_default/demo/data.xml b/fetchmail_thread_default/demo/data.xml index 14a6a95e..0e16d30d 100644 --- a/fetchmail_thread_default/demo/data.xml +++ b/fetchmail_thread_default/demo/data.xml @@ -1,5 +1,5 @@ - diff --git a/fetchmail_thread_default/models/__init__.py b/fetchmail_thread_default/models/__init__.py index 83b4f275..670ea5d4 100644 --- a/fetchmail_thread_default/models/__init__.py +++ b/fetchmail_thread_default/models/__init__.py @@ -1,6 +1,2 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Jairo Llopis -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from . import fetchmail_server from . import mail_thread diff --git a/fetchmail_thread_default/models/fetchmail_server.py b/fetchmail_thread_default/models/fetchmail_server.py index 6e002b72..57bc8ecb 100644 --- a/fetchmail_thread_default/models/fetchmail_server.py +++ b/fetchmail_thread_default/models/fetchmail_server.py @@ -1,8 +1,7 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Jairo Llopis +# Copyright 2017 Tecnativa - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import api, fields, models +from odoo import api, fields, models class FetchmailServer(models.Model): @@ -29,17 +28,12 @@ class FetchmailServer(models.Model): return [(m.model, m.name) for m in models if m.model in self.env and getattr(self.env[m.model], "_auto")] - # TODO New api on v10+ - # pylint: disable=old-api7-method-defined - def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False, - object_id=False): + @api.onchange('type', 'is_ssl', 'object_id') + def onchange_server_type(self): """Remove :attr:`default_thread_id` if there is :attr:`object_id`.""" - result = super(FetchmailServer, self).onchange_server_type( - cr, uid, ids, server_type, ssl, object_id, - ) - if object_id: - result["value"]["default_thread_id"] = False - return result + if self.object_id: + self.default_thread_id = False + return super(FetchmailServer, self).onchange_server_type() @api.multi @api.onchange("default_thread_id") diff --git a/fetchmail_thread_default/models/mail_thread.py b/fetchmail_thread_default/models/mail_thread.py index 58075ffa..d0797d9a 100644 --- a/fetchmail_thread_default/models/mail_thread.py +++ b/fetchmail_thread_default/models/mail_thread.py @@ -1,8 +1,7 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Jairo Llopis +# Copyright 2017 Tecnativa - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import api, models +from odoo import api, models class MailThread(models.AbstractModel): diff --git a/fetchmail_thread_default/readme/CONFIGURE.rst b/fetchmail_thread_default/readme/CONFIGURE.rst new file mode 100644 index 00000000..b163b948 --- /dev/null +++ b/fetchmail_thread_default/readme/CONFIGURE.rst @@ -0,0 +1,9 @@ +To configure this module, you need to: + +#. Go to *Settings > General Settings > Configure the incoming email gateway*. +#. Create or edit a record. +#. Configure properly. +#. Under *Default mail thread*, choose a model and record. + + Tip: if you do not know what to choose, we suggest you to use a mail + channel. diff --git a/fetchmail_thread_default/readme/CONTRIBUTORS.rst b/fetchmail_thread_default/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..4b173794 --- /dev/null +++ b/fetchmail_thread_default/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_: + + * Jairo Llopis + * David Vidal diff --git a/fetchmail_thread_default/readme/DESCRIPTION.rst b/fetchmail_thread_default/readme/DESCRIPTION.rst new file mode 100644 index 00000000..9d335296 --- /dev/null +++ b/fetchmail_thread_default/readme/DESCRIPTION.rst @@ -0,0 +1,16 @@ +This module extends the functionality of mail fetching to support choosing a +mail thread that acts as a mail sink and gathers all mail messages that Odoo +does not know where to put. + +Dangling emails are really a problem because if you do not care about them, +SPAM can enter your inbox and keep increasing fetchmail process network quota +because Odoo would gather them every time it runs the fetchmail process. + +Before this, your only choice was to create a new record for those unbounded +emails. That could be useful under some circumstances, like creating a +``crm.lead`` for them, but what happens if you do not want to have lots of +spammy leads? Or if you do not need Odoo's CRM at all? + +Here we come to the rescue. This simple addons adds almost none dependencies +and allows you to direct those mails somewhere you can handle or ignore at +wish. diff --git a/fetchmail_thread_default/readme/USAGE.rst b/fetchmail_thread_default/readme/USAGE.rst new file mode 100644 index 00000000..486d7c07 --- /dev/null +++ b/fetchmail_thread_default/readme/USAGE.rst @@ -0,0 +1,5 @@ +To use this module, you need to: + +#. Subscribe to the thread you chose as the *Default mail thread*. +#. You will be notified when a new unbound email lands in that thread. +#. Do what you want with it. diff --git a/fetchmail_thread_default/tests/__init__.py b/fetchmail_thread_default/tests/__init__.py index 13102356..6d46f428 100644 --- a/fetchmail_thread_default/tests/__init__.py +++ b/fetchmail_thread_default/tests/__init__.py @@ -1,5 +1 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Jairo Llopis -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from . import test_fetchmail diff --git a/fetchmail_thread_default/tests/test_fetchmail.py b/fetchmail_thread_default/tests/test_fetchmail.py index f245997b..7325ef3b 100644 --- a/fetchmail_thread_default/tests/test_fetchmail.py +++ b/fetchmail_thread_default/tests/test_fetchmail.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Jairo Llopis +# Copyright 2017 Tecnativa - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp.addons.mail.tests.test_mail_gateway import MAIL_TEMPLATE -from openerp.tests.common import SavepointCase -from openerp.tools import mute_logger +from odoo.addons.mail.tests.test_mail_gateway import MAIL_TEMPLATE +from odoo.tests.common import SavepointCase +from odoo.tools import mute_logger class FetchmailCase(SavepointCase): @@ -22,10 +21,9 @@ class FetchmailCase(SavepointCase): def test_emptying_default_thread(self): """Choosing an ``object_id`` empties ``default_thread_id``.""" - self.assertEqual( - self.server.onchange_server_type(object_id=1) - ["value"]["default_thread_id"], - False) + self.server.write({'object_id': 1}) + self.server.onchange_server_type() + self.assertFalse(self.server.default_thread_id) def test_emptying_object(self): """Choosing a ``default_thread_id`` empties ``object_id``.""" @@ -33,7 +31,7 @@ class FetchmailCase(SavepointCase): self.server._onchange_remove_object_id() self.assertFalse(self.server.object_id) - @mute_logger('openerp.addons.mail.models.mail_thread', 'openerp.models') + @mute_logger('odoo.addons.mail.models.mail_thread', 'odoo.models') def test_unbound_incoming_email(self): """An unbound incoming email gets posted to the sink.""" # Imitate what self.server.feth_mail() would do diff --git a/fetchmail_thread_default/views/fetchmail_server_view.xml b/fetchmail_thread_default/views/fetchmail_server_view.xml index 05422f13..ee7f84d3 100644 --- a/fetchmail_thread_default/views/fetchmail_server_view.xml +++ b/fetchmail_thread_default/views/fetchmail_server_view.xml @@ -1,5 +1,5 @@ -