[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.
This commit is contained in:
Toufik Benjaa
2018-08-13 15:58:08 +02:00
parent c69a6c6509
commit c605acd0a0
+14
View File
@@ -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)