mirror of https://github.com/OCA/social.git
[MIG] mail_restrict_follower_selection : Migration to 13.0
parent
ee66e363a0
commit
5c34bed5e8
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Restrict follower selection",
|
"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)",
|
"author": "Therp BV,Creu Blanca,Odoo Community Association (OCA)",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"category": "Social Network",
|
"category": "Social Network",
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
<odoo noupdate="1">
|
<odoo noupdate="1">
|
||||||
<record id="parameter_domain" model="ir.config_parameter">
|
<record id="parameter_domain" model="ir.config_parameter">
|
||||||
<field name="key">mail_restrict_follower_selection.domain</field>
|
<field name="key">mail_restrict_follower_selection.domain</field>
|
||||||
<field name="value">[('customer', '=', True)]</field>
|
<field name="value">[('category_id.name', '=', 'Employees')]</field>
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
from odoo import api, models
|
from odoo import models
|
||||||
from odoo.tools.safe_eval import safe_eval
|
from odoo.tools.safe_eval import safe_eval
|
||||||
|
|
||||||
|
|
||||||
class MailThread(models.AbstractModel):
|
class MailThread(models.AbstractModel):
|
||||||
_inherit = "mail.thread"
|
_inherit = "mail.thread"
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _message_add_suggested_recipient(
|
def _message_add_suggested_recipient(
|
||||||
self, result, partner=None, email=None, reason=""
|
self, result, partner=None, email=None, reason=""
|
||||||
):
|
):
|
||||||
|
|
|
@ -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!
|
|
@ -0,0 +1,3 @@
|
||||||
|
* Holger Brunn <hbrunn@therp.nl>
|
||||||
|
* Nguyen Tan Phuc <phuc.nt@komit-consulting.com>
|
||||||
|
* Enric Tobella <etobella@creublanca.es>
|
|
@ -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.
|
|
@ -10,8 +10,16 @@ from odoo.tests.common import TransactionCase
|
||||||
class TestMailRestrictFollowerSelection(TransactionCase):
|
class TestMailRestrictFollowerSelection(TransactionCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
self.category_employees = self.env["res.partner.category"].create(
|
||||||
|
{"name": "Employees"}
|
||||||
|
)
|
||||||
|
|
||||||
self.partner = self.env["res.partner"].create(
|
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):
|
def test_fields_view_get(self):
|
||||||
|
@ -45,16 +53,14 @@ class TestMailRestrictFollowerSelection(TransactionCase):
|
||||||
compose.action_send_mail()
|
compose.action_send_mail()
|
||||||
|
|
||||||
def test_followers_meet(self):
|
def test_followers_meet(self):
|
||||||
self.partner.write({"customer": True})
|
self.partner.write({"category_id": self.category_employees})
|
||||||
self.assertTrue(self.partner.customer)
|
|
||||||
self.send_action()
|
self.send_action()
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
self.partner, self.partner.message_follower_ids.mapped("partner_id")
|
self.partner, self.partner.message_follower_ids.mapped("partner_id")
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_followers_not_meet(self):
|
def test_followers_not_meet(self):
|
||||||
self.partner.write({"customer": False})
|
self.partner.write({"category_id": False})
|
||||||
self.assertFalse(self.partner.customer)
|
|
||||||
self.send_action()
|
self.send_action()
|
||||||
self.assertNotIn(
|
self.assertNotIn(
|
||||||
self.partner, self.partner.message_follower_ids.mapped("partner_id")
|
self.partner, self.partner.message_follower_ids.mapped("partner_id")
|
||||||
|
|
Loading…
Reference in New Issue