[FIX] [crm_]mail_plugin: fix multi_company access error

This commit fixes the multi_company access error when the user is attempting to
see a record belonging to another company then the one he is logged in to from
the plugins, upon login, it returns all the company ids related to the user so
that the plugin redirects the user to the record with all companies ticked.

Task-2541205

closes odoo/odoo#72529

Plugin-pr: https://github.com/odoo/mail-client-extensions/pull/10
X-original-commit: 92972fa16920e070e533040439243a0257357aad
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
nounoubensebia
2021-06-22 11:52:30 +00:00
parent e07bda1d4d
commit aa02285b0a
2 changed files with 4 additions and 9 deletions
@@ -45,9 +45,6 @@ class CrmClient(http.Controller):
if not partner:
return {'error': 'partner_not_found'}
# In a multi-company environment, we will not be able to create a lead if the user is connected to a different
# company then the one linked to the contact, this is not supported, and users are encouraged to check if they
# are connected to the right company before performing such operation.
record = request.env['crm.lead'].create({
'name': html2plaintext(email_subject),
'partner_id': partner_id,
@@ -111,11 +111,6 @@ class MailPluginController(http.Controller):
The method returns an array containing the dicts of the matched contacts.
"""
#In a multi-company environment, the method may return contacts not belonging to the company that the user
#is connected to, this may result in the user not being able to view the contact in Odoo, while this may happen
#it is not supported for now and users are encouraged to check if they are connected to the correct company before
# clicking on a contact.
normalized_email = tools.email_normalize(search_term)
if normalized_email:
@@ -313,7 +308,10 @@ class MailPluginController(http.Controller):
else: # no partner found
partner_response = {}
return {'partner': partner_response}
return {
'partner': partner_response,
'user_companies': request.env['res.users'].browse(request.uid).company_ids.ids
}
def _mail_content_logging_models_whitelist(self):
"""