summaryrefslogtreecommitdiff
path: root/addons/mail
diff options
context:
space:
mode:
authorAnh Thao Pham (pta) <pta@odoo.com>2021-02-11 09:40:00 +0000
committerAnh Thao Pham (pta) <pta@odoo.com>2021-03-29 14:31:23 +0000
commit20536e1bbeb641539c0de44364f8376e7cef651b (patch)
tree59f731c45a7bfcad2fd712317515f43c22c556c0 /addons/mail
parent43bf5a5f048115a94eecc7a23a7e3fea119ac76c (diff)
[FIX] mail: prevent use of private addresses for followers, recipients,...
- Connect with Admin - Go to Contacts, edit himself by adding a Private Address - Create an Internal User without "Access to Private Addresses" right (i.e. User X) - Go to any app implementing chatter (i.e. Sales) - Create a SO - Add the created Private Address as follower - Make sure User X can access the record (i.e. Sales: Administrator) - Connect with User X and open the SO An Access Error is raised while trying to fetch data about the followers. This commit prevents to: - add a private address as follower of a record - add a private address as Recipient in full composer - propose private addresses when adding a mention to a partner opw-2428936 closes odoo/odoo#65933 Task-id: 2463622 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/mail')
-rw-r--r--addons/mail/models/mail_followers.py2
-rw-r--r--addons/mail/models/mail_thread.py4
-rw-r--r--addons/mail/models/res_partner.py2
-rw-r--r--addons/mail/wizard/invite.py3
-rw-r--r--addons/mail/wizard/mail_compose_message.py3
5 files changed, 8 insertions, 6 deletions
diff --git a/addons/mail/models/mail_followers.py b/addons/mail/models/mail_followers.py
index 8995de70acf..e584b87dd10 100644
--- a/addons/mail/models/mail_followers.py
+++ b/addons/mail/models/mail_followers.py
@@ -29,7 +29,7 @@ class Followers(models.Model):
res_id = fields.Many2oneReference(
'Related Document ID', index=True, help='Id of the followed resource', model_field='res_model')
partner_id = fields.Many2one(
- 'res.partner', string='Related Partner', ondelete='cascade', index=True)
+ 'res.partner', string='Related Partner', ondelete='cascade', index=True, domain=[('type', '!=', 'private')])
channel_id = fields.Many2one(
'mail.channel', string='Listener', ondelete='cascade', index=True)
subtype_ids = fields.Many2many(
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index 8c27eed7703..4c85ef53044 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -2666,9 +2666,9 @@ class MailThread(models.AbstractModel):
self.check_access_rights('write')
self.check_access_rule('write')
- # filter inactive
+ # filter inactive and private addresses
if partner_ids and not adding_current:
- partner_ids = self.env['res.partner'].sudo().search([('id', 'in', partner_ids), ('active', '=', True)]).ids
+ partner_ids = self.env['res.partner'].sudo().search([('id', 'in', partner_ids), ('active', '=', True), ('type', '!=', 'private')]).ids
return self._message_subscribe(partner_ids, channel_ids, subtype_ids, customer_ids=customer_ids)
diff --git a/addons/mail/models/res_partner.py b/addons/mail/models/res_partner.py
index ce1fcb35a23..08b948059d4 100644
--- a/addons/mail/models/res_partner.py
+++ b/addons/mail/models/res_partner.py
@@ -130,7 +130,7 @@ class Partner(models.Model):
If channel_id is given, only members of this channel are returned.
"""
search_dom = expression.OR([[('name', 'ilike', search)], [('email', 'ilike', search)]])
- search_dom = expression.AND([[('active', '=', True)], search_dom])
+ search_dom = expression.AND([[('active', '=', True), ('type', '!=', 'private')], search_dom])
if channel_id:
search_dom = expression.AND([[('channel_ids', 'in', channel_id)], search_dom])
diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py
index 610b1a0dd3e..8b6a2de8342 100644
--- a/addons/mail/wizard/invite.py
+++ b/addons/mail/wizard/invite.py
@@ -41,7 +41,8 @@ class Invite(models.TransientModel):
res_model = fields.Char('Related Document Model', required=True, index=True, help='Model of the followed resource')
res_id = fields.Integer('Related Document ID', index=True, help='Id of the followed resource')
- partner_ids = fields.Many2many('res.partner', string='Recipients', help="List of partners that will be added as follower of the current document.")
+ partner_ids = fields.Many2many('res.partner', string='Recipients', help="List of partners that will be added as follower of the current document.",
+ domain=[('type', '!=', 'private')])
channel_ids = fields.Many2many('mail.channel', string='Channels', help='List of channels that will be added as listeners of the current document.',
domain=[('channel_type', '=', 'channel')])
message = fields.Html('Message')
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index a75cc2a1367..b71a6fe8a74 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -131,7 +131,8 @@ class MailComposer(models.TransientModel):
help='Whether the message is an internal note (comment mode only)')
partner_ids = fields.Many2many(
'res.partner', 'mail_compose_message_res_partner_rel',
- 'wizard_id', 'partner_id', 'Additional Contacts')
+ 'wizard_id', 'partner_id', 'Additional Contacts',
+ domain=[('type', '!=', 'private')])
# mass mode options
notify = fields.Boolean('Notify followers', help='Notify followers of the document (mass post only)')
auto_delete = fields.Boolean('Delete Emails',