[12.0][MIG] mail_restrict_follower_selection
This commit is contained in:
parent
9c3576e1df
commit
1c713ad24a
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Restrict follower selection",
|
"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)",
|
"author": "Therp BV,Creu Blanca,Odoo Community Association (OCA)",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"category": "Social Network",
|
"category": "Social Network",
|
||||||
@ -16,10 +16,5 @@
|
|||||||
"data/ir_config_parameter.xml",
|
"data/ir_config_parameter.xml",
|
||||||
"data/ir_actions.xml",
|
"data/ir_actions.xml",
|
||||||
],
|
],
|
||||||
"auto_install": False,
|
|
||||||
'installable': True,
|
'installable': True,
|
||||||
"application": False,
|
|
||||||
"external_dependencies": {
|
|
||||||
'python': [],
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,31 @@
|
|||||||
# Copyright (C) 2018 Creu Blanca
|
# Copyright (C) 2018 Creu Blanca
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# 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
|
from odoo.tools.safe_eval import safe_eval
|
||||||
|
|
||||||
|
|
||||||
class MailFollowers(models.Model):
|
class MailFollowers(models.Model):
|
||||||
_inherit = 'mail.followers'
|
_inherit = 'mail.followers'
|
||||||
|
|
||||||
@api.model
|
def _add_followers(self, res_model, res_ids, partner_ids, partner_subtypes,
|
||||||
def _add_follower_command(self, res_model, res_ids, partner_data,
|
channel_ids, channel_subtypes,
|
||||||
channel_data, force=True):
|
check_existing=False, existing_policy='skip'):
|
||||||
domain = self.env[
|
domain = self.env[
|
||||||
'mail.wizard.invite'
|
'mail.wizard.invite'
|
||||||
]._mail_restrict_follower_selection_get_domain()
|
]._mail_restrict_follower_selection_get_domain()
|
||||||
partners = self.env['res.partner'].search(
|
partners = self.env['res.partner'].search(
|
||||||
[('id', 'in', list(partner_data))] +
|
[('id', 'in', partner_ids)] +
|
||||||
safe_eval(domain)
|
safe_eval(domain)
|
||||||
)
|
)
|
||||||
return super()._add_follower_command(
|
_res_ids = res_ids.copy() or [0]
|
||||||
res_model, res_ids,
|
new, update = super()._add_followers(
|
||||||
{p.id: partner_data[p.id] for p in partners},
|
res_model, res_ids, partners.ids, partner_subtypes, channel_ids,
|
||||||
channel_data, force=force)
|
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
|
||||||
|
@ -36,7 +36,7 @@ class TestMailRestrictFollowerSelection(TransactionCase):
|
|||||||
'partner_ids': [(4, id) for id in self.partner.ids],
|
'partner_ids': [(4, id) for id in self.partner.ids],
|
||||||
})
|
})
|
||||||
self.assertEqual(compose.partner_ids, self.partner)
|
self.assertEqual(compose.partner_ids, self.partner)
|
||||||
compose.send_mail_action()
|
compose.action_send_mail()
|
||||||
|
|
||||||
def test_followers_meet(self):
|
def test_followers_meet(self):
|
||||||
self.partner.write({'customer': True})
|
self.partner.write({'customer': True})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user