[IMP] mail: use _notify_get_action_link and not inline string

Note that this also add data-oe-model and data-oe-id in XML.
This allow us to avoid to load these links as external URL when
a user receive it in inbox instead of external mail client.
See file addons/mail/static/src/js/thread_widget.js -> _onClickRedirect

Task ID: 1895451

closes odoo/odoo#39958

Related: odoo/enterprise#6414
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
This commit is contained in:
Romeo Fragomeli
2019-12-02 09:10:34 +00:00
parent a82fd08813
commit ecc028c0e8
3 changed files with 8 additions and 3 deletions
+2 -2
View File
@@ -308,7 +308,7 @@
<span style="margin-top: 8px;">You have been assigned to the <t t-esc="model_description or 'document'"/> <t t-esc="object.display_name"/>.</span>
</p>
<p style="margin-top: 24px; margin-bottom: 16px;">
<a t-att-href="'/mail/view?model=%s&amp;res_id=%s' % (object._name, object.id)" style="background-color:#875A7B; padding: 10px; text-decoration: none; color: #fff; border-radius: 5px;">
<a t-att-href="access_link" t-att-data-oe-model="object._name" t-att-data-oe-id="object.id" style="background-color:#875A7B; padding: 10px; text-decoration: none; color: #fff; border-radius: 5px;">
View <t t-esc="model_description or 'document'"/>
</a>
</p>
@@ -341,7 +341,7 @@
on <span t-field="activity.res_name"/>
to close for <span t-field="activity.date_deadline"/>.<br />
<p style="margin: 16px 0px 16px 0px;">
<a t-att-href="'/mail/view?model=%s&amp;res_id=%s' % (activity.res_model, activity.res_id)"
<a t-att-href="access_link" t-att-data-oe-model="activity.res_model" t-att-data-oe-id="activity.res_id"
style="background-color:#875A7B; padding: 8px 16px 8px 16px; text-decoration: none; color: #fff; border-radius: 5px;">
View <t t-esc="model_description or 'document'"/>
</a>
+5 -1
View File
@@ -387,7 +387,11 @@ class MailActivity(models.Model):
for activity in self:
model_description = self.env['ir.model']._get(activity.res_model).display_name
body = body_template.render(
dict(activity=activity, model_description=model_description),
dict(
activity=activity,
model_description=model_description,
access_link=self.env['mail.thread']._notify_get_action_link('view', model=activity.res_model, res_id=activity.res_id),
),
engine='ir.qweb',
minimal_qcontext=True
)
+1
View File
@@ -2812,6 +2812,7 @@ class MailThread(models.AbstractModel):
values = {
'object': record,
'model_description': model_description,
'access_link': self._notify_get_action_link('view'),
}
assignation_msg = view.render(values, engine='ir.qweb', minimal_qcontext=True)
assignation_msg = self.env['mail.thread']._replace_local_links(assignation_msg)