diff --git a/mail_restrict_follower_selection/__manifest__.py b/mail_restrict_follower_selection/__manifest__.py
index a2073229a..39115020b 100644
--- a/mail_restrict_follower_selection/__manifest__.py
+++ b/mail_restrict_follower_selection/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Restrict follower selection",
- "version": "12.0.1.0.0",
+ "version": "13.0.1.0.0",
"author": "Therp BV,Creu Blanca,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Social Network",
diff --git a/mail_restrict_follower_selection/data/ir_config_parameter.xml b/mail_restrict_follower_selection/data/ir_config_parameter.xml
index f4a1daf2e..3602566e3 100644
--- a/mail_restrict_follower_selection/data/ir_config_parameter.xml
+++ b/mail_restrict_follower_selection/data/ir_config_parameter.xml
@@ -2,6 +2,6 @@
mail_restrict_follower_selection.domain
- [('customer', '=', True)]
+ [('category_id.name', '=', 'Employees')]
diff --git a/mail_restrict_follower_selection/models/mail_thread.py b/mail_restrict_follower_selection/models/mail_thread.py
index 0bacf177f..019307988 100644
--- a/mail_restrict_follower_selection/models/mail_thread.py
+++ b/mail_restrict_follower_selection/models/mail_thread.py
@@ -1,11 +1,10 @@
-from odoo import api, models
+from odoo import models
from odoo.tools.safe_eval import safe_eval
class MailThread(models.AbstractModel):
_inherit = "mail.thread"
- @api.multi
def _message_add_suggested_recipient(
self, result, partner=None, email=None, reason=""
):
diff --git a/mail_restrict_follower_selection/readme/CONFIGURE.rst b/mail_restrict_follower_selection/readme/CONFIGURE.rst
new file mode 100644
index 000000000..9c233086a
--- /dev/null
+++ b/mail_restrict_follower_selection/readme/CONFIGURE.rst
@@ -0,0 +1,11 @@
+To configure this module, you need to go to `System parameters` and adjust
+`mail_restrict_follower_selection.domain` as you see fit. This restricts
+followers globally, if you want to restrict only the followers for a certain
+record type (or have different restrictions for different record types),
+create a parameter `mail_restrict_follower_selection.domain.$your_model`.
+
+As an example, you could use `[('category_id.name', '=', 'Employees')]` to allow
+only contacts with 'Employees' tag to be added as follower - this also is
+the default.
+
+Note: This module won't change existing followers!
diff --git a/mail_restrict_follower_selection/readme/CONTRIBUTORS.rst b/mail_restrict_follower_selection/readme/CONTRIBUTORS.rst
new file mode 100644
index 000000000..47b2b8d31
--- /dev/null
+++ b/mail_restrict_follower_selection/readme/CONTRIBUTORS.rst
@@ -0,0 +1,3 @@
+* Holger Brunn
+* Nguyen Tan Phuc
+* Enric Tobella
diff --git a/mail_restrict_follower_selection/readme/DESCRIPTION.rst b/mail_restrict_follower_selection/readme/DESCRIPTION.rst
new file mode 100644
index 000000000..d8867e560
--- /dev/null
+++ b/mail_restrict_follower_selection/readme/DESCRIPTION.rst
@@ -0,0 +1,7 @@
+This module was written to allow you to restrict the selection of possible
+followers. For example, if you use the social ERP functions only internally,
+it makes sense to filter possible followers for being employees. Otherwise,
+you'll get a quite crowded list of partners to choose from.
+
+Moreover, the module disables the option to automatically add followers that
+do not meet the domain.
diff --git a/mail_restrict_follower_selection/tests/test_mail_restrict_follower_selection.py b/mail_restrict_follower_selection/tests/test_mail_restrict_follower_selection.py
index 0b78d650c..c4ce705d8 100644
--- a/mail_restrict_follower_selection/tests/test_mail_restrict_follower_selection.py
+++ b/mail_restrict_follower_selection/tests/test_mail_restrict_follower_selection.py
@@ -10,8 +10,16 @@ from odoo.tests.common import TransactionCase
class TestMailRestrictFollowerSelection(TransactionCase):
def setUp(self):
super().setUp()
+ self.category_employees = self.env["res.partner.category"].create(
+ {"name": "Employees"}
+ )
+
self.partner = self.env["res.partner"].create(
- {"name": "Partner", "customer": True, "email": "test@test.com"}
+ {
+ "name": "Partner",
+ "category_id": self.category_employees,
+ "email": "test@test.com",
+ }
)
def test_fields_view_get(self):
@@ -45,16 +53,14 @@ class TestMailRestrictFollowerSelection(TransactionCase):
compose.action_send_mail()
def test_followers_meet(self):
- self.partner.write({"customer": True})
- self.assertTrue(self.partner.customer)
+ self.partner.write({"category_id": self.category_employees})
self.send_action()
self.assertIn(
self.partner, self.partner.message_follower_ids.mapped("partner_id")
)
def test_followers_not_meet(self):
- self.partner.write({"customer": False})
- self.assertFalse(self.partner.customer)
+ self.partner.write({"category_id": False})
self.send_action()
self.assertNotIn(
self.partner, self.partner.message_follower_ids.mapped("partner_id")