Browse Source

Merge f6d43b0b7c into 975b033a76

pull/161/merge
Lois Rilo 5 years ago
committed by GitHub
parent
commit
431e2d4dce
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 79
      mail_auto_follower_notify/README.rst
  2. 6
      mail_auto_follower_notify/__init__.py
  3. 18
      mail_auto_follower_notify/__openerp__.py
  4. 6
      mail_auto_follower_notify/models/__init__.py
  5. 29
      mail_auto_follower_notify/models/mail_thread.py
  6. 4
      mail_auto_follower_notify/tests/__init__.py
  7. 36
      mail_auto_follower_notify/tests/test_auto_follower_notify.py
  8. 1
      oca_dependencies.txt

79
mail_auto_follower_notify/README.rst

@ -0,0 +1,79 @@
.. 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
=========================
Mail Auto Follower Notify
=========================
With this module users assigned to leads, tasks, issues... will receive an
automatic notification in their email address containing the last discussion
message in the thread.
Some instances where this is valuable is when a lead is created from an
incoming email, and a sales manager assigns it to a salesman. This person
will then receive a notification in his mailbox including the details of the
email from the customer.
This feature existed in 8.0, but was removed as of 9.0.
Configuration
=============
In order to work correctly, the model must meet the following conditions:
* Should inherit from 'mail.thread'.
* The field representing the user should have *track_visibility='onchange'*
in the field definition.
Usage
=====
To use this module, you need to:
#. Start a conversation for an existing record (e.g. Lead, Task..).
#. Assign the record to a user.
#. A email notification is sent to the assigned user containing the last
conversation message.
.. 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.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Lois Rilo <lois.rilo@eficent.com>
* Jordi Ballester <jordi.ballester@eficent.com>
Maintainer
----------
.. 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.

6
mail_auto_follower_notify/__init__.py

@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import models

18
mail_auto_follower_notify/__openerp__.py

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Mail Auto Follower Notify",
"summary": "This module extends the functionality of mail by sending an "
"email notification to new followers that are system users",
"author": "Eficent, "
"Odoo Community Association (OCA)",
"website": "https://odoo-community.org/",
"category": "Mail",
"depends": ["mail", "base_patch_models_mixin"],
"license": "AGPL-3",
'installable': True,
'application': False,
}

6
mail_auto_follower_notify/models/__init__.py

@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import mail_thread

29
mail_auto_follower_notify/models/mail_thread.py

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openerp import api, models
class MailThread(models.AbstractModel):
_name = 'mail.thread'
_inherit = ['base.patch.models.mixin', 'mail.thread']
@api.multi
def _message_auto_subscribe_notify(self, partner_ids):
"""This is added in order to send an email notification to new
followers that are system users (i.e. it won't send emails to
customers)."""
super(MailThread, self)._message_auto_subscribe_notify(partner_ids)
if not partner_ids:
return
for record_id in self.ids:
messages = self.env['mail.message'].sudo().search([
('model', '=', self._name),
('res_id', '=', record_id),
('subtype_id', '!=', False),
('subtype_id.internal', '=', False)], limit=1)
if messages:
self.env['res.partner'].browse(partner_ids)._notify(
messages, force_send=True)

4
mail_auto_follower_notify/tests/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import test_auto_follower_notify

36
mail_auto_follower_notify/tests/test_auto_follower_notify.py

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.tests.common import TransactionCase, at_install, post_install
class TestAutoFollowerNotify(TransactionCase):
def setUp(self):
super(TestAutoFollowerNotify, self).setUp()
self.test_record = self.env['res.partner'].create({
'name': 'Test Record',
})
self.user = self.env['res.users'].create({
'name': 'Test user',
'login': 'test_login',
'password': 'demo',
'email': 'test@yourcompany.com',
})
@at_install(False)
@post_install(True)
def test_something(self):
"""Test module functionality. The test must be run after the
installation to ensure that the patch done in
``base_patch_models_mixin`` is applied."""
# Set manually a res.users field to track visibility in order to be
# able to test the module without extra dependencies.
items = self.test_record._fields.items()
user_id = filter(lambda (n, f): n == 'user_id', items)
setattr(user_id[0][1], 'track_visibility', 'always')
# Update the field with a user:
self.test_record.user_id = self.user.id
self.assertTrue(
self.test_record.message_follower_ids, "Follower not notified.")

1
oca_dependencies.txt

@ -1,2 +1,3 @@
partner-contact
server-tools
server-tools-eficent https://github.com/eficent/server-tools 9.0-add-base_patch_models_mixin
Loading…
Cancel
Save