fixes a corner case where you could send an email to a partner

that you are not supposed to.
This commit is contained in:
Jordi Ballester Alomar 2020-01-23 15:18:11 +01:00 committed by Aungkokolin1997
parent b8bd728bcb
commit 9c3576e1df
9 changed files with 62 additions and 1 deletions

View File

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_restrict_follower_selection
# * mail_restrict_follower_selection
#
msgid ""
msgstr ""
@ -26,6 +26,11 @@ msgstr "Beschränkung der Abonnenten konfigurieren"
msgid "Document Followers"
msgstr "Abonnenten des Dokuments"
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_thread
msgid "Email Thread"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_wizard_invite
msgid "Invite wizard"

View File

@ -28,6 +28,11 @@ msgstr "Configure the restriction on followers"
msgid "Document Followers"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_thread
msgid "Email Thread"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_wizard_invite
msgid "Invite wizard"

View File

@ -29,6 +29,11 @@ msgstr "Configurer les restrictions sur les abonnés"
msgid "Document Followers"
msgstr "Suiveurs du document"
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_thread
msgid "Email Thread"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_wizard_invite
msgid "Invite wizard"

View File

@ -29,6 +29,11 @@ msgstr "Postavi ograničenja na pratitelje"
msgid "Document Followers"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_thread
msgid "Email Thread"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_wizard_invite
msgid "Invite wizard"

View File

@ -28,6 +28,11 @@ msgstr "Imposta restrizioni sui follower"
msgid "Document Followers"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_thread
msgid "Email Thread"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_wizard_invite
msgid "Invite wizard"

View File

@ -23,6 +23,11 @@ msgstr ""
msgid "Document Followers"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_thread
msgid "Email Thread"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_wizard_invite
msgid "Invite wizard"

View File

@ -30,6 +30,11 @@ msgstr "Nastavitev omejitev za sledilce"
msgid "Document Followers"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_thread
msgid "Email Thread"
msgstr ""
#. module: mail_restrict_follower_selection
#: model:ir.model,name:mail_restrict_follower_selection.model_mail_wizard_invite
msgid "Invite wizard"

View File

@ -4,3 +4,4 @@
from . import mail_followers
from . import mail_wizard_invite
from . import mail_thread

View File

@ -0,0 +1,25 @@
from odoo import api, 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=''):
result = super(MailThread, self)._message_add_suggested_recipient(
result, partner=partner, email=email, reason=reason)
domain = self.env[
'mail.wizard.invite'
]._mail_restrict_follower_selection_get_domain()
eval_domain = safe_eval(domain)
for key in result:
for partner_id, email, reason in result[key]:
if partner_id:
partner = self.env['res.partner'].search(
[('id', '=', partner_id)] + eval_domain
)
if not partner:
result[key].remove((partner_id, email, reason))
return result