summaryrefslogtreecommitdiff
path: root/addons/mail/controllers
diff options
context:
space:
mode:
authorToufik Benjaa <tbe@odoo.com>2018-08-13 15:58:08 +0200
committerToufik Benjaa <tbe@odoo.com>2018-08-13 15:58:08 +0200
commitc605acd0a02af988d51c5ca9acd3dc01eaeba0bd (patch)
treef9e25fa2f729c5e5f8a9e0f31a6bd80e685fd87d /addons/mail/controllers
parentc69a6c6509fb3c0c44455b83676a415fde8bb403 (diff)
[FIX] mail: Keep backward compatibility on route /mail/view
- If a database is migrated from an older version to saas-11.3 without this patch, all the links /mail/view with a message_id as parameter will not work. We must keep the backward compatibility for those links.
Diffstat (limited to 'addons/mail/controllers')
-rw-r--r--addons/mail/controllers/main.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py
index 9a57808f057..4bd5e52a1a7 100644
--- a/addons/mail/controllers/main.py
+++ b/addons/mail/controllers/main.py
@@ -176,6 +176,20 @@ class MailController(http.Controller):
models that have an access_token may apply variations on this.
"""
+ # ==============================================================================================
+ # This block of code disappeared on saas-11.3 to be reintroduced by TBE.
+ # This is needed because after a migration from an older version to saas-11.3, the link
+ # received by mail with a message_id no longer work.
+ # So this block of code is needed to guarantee the backward compatibility of those links.
+ if kwargs.get('message_id'):
+ try:
+ message = request.env['mail.message'].sudo().browse(int(kwargs['message_id'])).exists()
+ except:
+ message = request.env['mail.message']
+ if message:
+ model, res_id = message.model, message.res_id
+ # ==============================================================================================
+
if res_id and isinstance(res_id, pycompat.string_types):
res_id = int(res_id)
return self._redirect_to_record(model, res_id, access_token)