[FW][MERGE][FIX] mail_plugin: provide various fixes

This merge fixes several bugs appearing when using mail plugin.
Notably

  * do not crash if customer is removed while being used in plugin;
  * fix a console error when not logging to the addin;
  * add a missing sentence to translate;
  * improve partial searches on email;

See sub commits for more details.

Task-2601837

closes odoo/odoo#89848

Forward-port-of: odoo/odoo#85101
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Odoo's Mergebot
2022-04-27 15:31:49 +02:00
committed by GitHub
4 changed files with 13 additions and 4 deletions
@@ -55,7 +55,7 @@ class Authenticate(http.Controller):
# In this case, an exception will be thrown in case of preflight request if only POST is allowed.
@http.route(['/mail_client_extension/auth/access_token', '/mail_plugin/auth/access_token'], type='json', auth="none", cors="*",
methods=['POST', 'OPTIONS'])
def auth_access_token(self, auth_code, **kw):
def auth_access_token(self, auth_code='', **kw):
"""
Called by the external app to exchange an auth code, which is temporary and was passed in a URL, for an
access token, which is permanent, and can be used in the `Authorization` header to authorize subsequent requests
@@ -63,6 +63,8 @@ class Authenticate(http.Controller):
old route name "/mail_client_extension/auth/access_token is deprecated as of saas-14.3,it is not needed for newer
versions of the mail plugin but necessary for supporting older versions
"""
if not auth_code:
return {"error": "Invalid code"}
auth_message = self._get_auth_code_data(auth_code)
if not auth_message:
return {"error": "Invalid code"}
@@ -144,7 +144,7 @@ class MailPluginController(http.Controller):
return {'error': _('You need to specify at least the partner_id or the name and the email')}
if partner_id:
partner = request.env['res.partner'].browse(partner_id)
partner = request.env['res.partner'].browse(partner_id).exists()
return self._get_contact_data(partner)
normalized_email = tools.email_normalize(email)
@@ -184,11 +184,10 @@ class MailPluginController(http.Controller):
search on.
The method returns an array containing the dicts of the matched contacts.
"""
normalized_email = tools.email_normalize(search_term)
if normalized_email:
filter_domain = [('email_normalized', '=', search_term)]
filter_domain = [('email_normalized', 'ilike', search_term)]
else:
filter_domain = ['|', '|', ('display_name', 'ilike', search_term), ('ref', '=', search_term),
('email', 'ilike', search_term)]
+7
View File
@@ -645,6 +645,13 @@ msgstr ""
msgid "Save in Odoo"
msgstr ""
#. module: mail_plugin
#. openerp-web
#: code:addons/mail_plugin/static/src/to_translate/translations_outlook.xml:0
#, python-format
msgid "Save the contact to create the company"
msgstr ""
#. module: mail_plugin
#. openerp-web
#: code:addons/mail_plugin/static/src/to_translate/translations_gmail.xml:0
@@ -48,4 +48,5 @@
<string>From : %(email)s</string>
<string>Logged from</string>
<string>Outlook Inbox</string>
<string>Save the contact to create the company</string>
</resources>