[12.0][MIG] mail_restrict_follower_selection

This commit is contained in:
Enric Tobella 2020-03-04 16:27:05 +01:00 committed by Aungkokolin1997
parent 9c3576e1df
commit 1c713ad24a
3 changed files with 18 additions and 16 deletions

View File

@ -4,7 +4,7 @@
{
"name": "Restrict follower selection",
"version": "11.0.2.0.0",
"version": "12.0.1.0.0",
"author": "Therp BV,Creu Blanca,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Social Network",
@ -16,10 +16,5 @@
"data/ir_config_parameter.xml",
"data/ir_actions.xml",
],
"auto_install": False,
'installable': True,
"application": False,
"external_dependencies": {
'python': [],
},
}

View File

@ -1,24 +1,31 @@
# Copyright (C) 2018 Creu Blanca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, models
from odoo import models
from odoo.tools.safe_eval import safe_eval
class MailFollowers(models.Model):
_inherit = 'mail.followers'
@api.model
def _add_follower_command(self, res_model, res_ids, partner_data,
channel_data, force=True):
def _add_followers(self, res_model, res_ids, partner_ids, partner_subtypes,
channel_ids, channel_subtypes,
check_existing=False, existing_policy='skip'):
domain = self.env[
'mail.wizard.invite'
]._mail_restrict_follower_selection_get_domain()
partners = self.env['res.partner'].search(
[('id', 'in', list(partner_data))] +
[('id', 'in', partner_ids)] +
safe_eval(domain)
)
return super()._add_follower_command(
res_model, res_ids,
{p.id: partner_data[p.id] for p in partners},
channel_data, force=force)
_res_ids = res_ids.copy() or [0]
new, update = super()._add_followers(
res_model, res_ids, partners.ids, partner_subtypes, channel_ids,
channel_subtypes, check_existing=check_existing,
existing_policy=existing_policy
)
for res_id in _res_ids:
if res_id not in new:
new.setdefault(res_id, list())
return new, update

View File

@ -36,7 +36,7 @@ class TestMailRestrictFollowerSelection(TransactionCase):
'partner_ids': [(4, id) for id in self.partner.ids],
})
self.assertEqual(compose.partner_ids, self.partner)
compose.send_mail_action()
compose.action_send_mail()
def test_followers_meet(self):
self.partner.write({'customer': True})