Browse Source

[MIG] fetch_thread_default: Migration to 11.0

pull/339/head
David 6 years ago
parent
commit
add4bd178c
  1. 74
      fetchmail_thread_default/README.rst
  2. 4
      fetchmail_thread_default/__init__.py
  3. 7
      fetchmail_thread_default/__manifest__.py
  4. 2
      fetchmail_thread_default/demo/data.xml
  5. 4
      fetchmail_thread_default/models/__init__.py
  6. 20
      fetchmail_thread_default/models/fetchmail_server.py
  7. 5
      fetchmail_thread_default/models/mail_thread.py
  8. 9
      fetchmail_thread_default/readme/CONFIGURE.rst
  9. 4
      fetchmail_thread_default/readme/CONTRIBUTORS.rst
  10. 16
      fetchmail_thread_default/readme/DESCRIPTION.rst
  11. 5
      fetchmail_thread_default/readme/USAGE.rst
  12. 4
      fetchmail_thread_default/tests/__init__.py
  13. 18
      fetchmail_thread_default/tests/test_fetchmail.py
  14. 2
      fetchmail_thread_default/views/fetchmail_server_view.xml

74
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
<https://github.com/OCA/social/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 <https://github.com/OCA/social/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 <https://github.com/OCA/social/issues/new?body=module:%20fetchmail_thread_default%0Aversion:%2011.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.
Credits
=======
Images
------
Authors
~~~~~~~
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
* Tecnativa
Contributors
------------
~~~~~~~~~~~~
* Jairo Llopis <jairo.llopis@tecnativa.com>
* `Tecnativa <https://www.tecnativa.com>`_:
Funders
-------
* Jairo Llopis
* David Vidal
The development of this module has been financially supported by:
Maintainers
~~~~~~~~~~~
* `Tecnativa <https://www.tecnativa.com>`_.
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 <https://github.com/OCA/social/tree/11.0/fetchmail_thread_default>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

4
fetchmail_thread_default/__init__.py

@ -1,5 +1 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

7
fetchmail_thread_default/__openerp__.py → fetchmail_thread_default/__manifest__.py

@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# Copyright 2017 Tecnativa - Jairo Llopis <jairo.llopis@tecnativa.com>
# 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,

2
fetchmail_thread_default/demo/data.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
<!-- Copyright 2017 Tecnativa - Jairo Llopis <jairo.llopis@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

4
fetchmail_thread_default/models/__init__.py

@ -1,6 +1,2 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import fetchmail_server
from . import mail_thread

20
fetchmail_thread_default/models/fetchmail_server.py

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# Copyright 2017 Tecnativa - Jairo Llopis <jairo.llopis@tecnativa.com>
# 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")

5
fetchmail_thread_default/models/mail_thread.py

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# Copyright 2017 Tecnativa - Jairo Llopis <jairo.llopis@tecnativa.com>
# 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):

9
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.

4
fetchmail_thread_default/readme/CONTRIBUTORS.rst

@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`_:
* Jairo Llopis
* David Vidal

16
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.

5
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.

4
fetchmail_thread_default/tests/__init__.py

@ -1,5 +1 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_fetchmail

18
fetchmail_thread_default/tests/test_fetchmail.py

@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# Copyright 2017 Tecnativa - Jairo Llopis <jairo.llopis@tecnativa.com>
# 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

2
fetchmail_thread_default/views/fetchmail_server_view.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
<!-- Copyright 2017 Tecnativa - Jairo Llopis <jairo.llopis@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

Loading…
Cancel
Save