Skip to content
Snippets Groups Projects
Commit be5e8fda authored by Patrick Hoste's avatar Patrick Hoste
Browse files

[FIX] eLearning: allow portal user to share a slide by mail


Before, a portal user who tried to share a slide by mail got
a Odoo Server Error. He will now be able to share it without
any error.

closes odoo/odoo#34320

Signed-off-by: default avatarThibault Delavallee (tde) <tde@openerp.com>
parent f3b6ff0c
Branches
Tags
No related merge requests found
......@@ -29,14 +29,14 @@
<record id="slide_template_shared" model="mail.template">
<field name="name">Slide Shared</field>
<field name="model_id" ref="model_slide_slide"/>
<field name="subject">${user.name} shared a ${object.slide_type} with you!</field>
<field name="email_from">${(user.email or '')|safe}</field>
<field name="subject">${ctx['user'].name} shared a ${object.slide_type} with you!</field>
<field name="email_from">${(ctx['user'].email or '')|safe}</field>
<field name="email_to">${ctx['email']}</field>
<field name="body_html" type="html">
<div style="margin: 0px; padding: 0px;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
Hello<br/><br/>
${user.name} shared the ${object.slide_type} <strong>${object.name}</strong> with you!
${ctx['user'].name} shared the ${object.slide_type} <strong>${object.name}</strong> with you!
<div style="margin: 16px 8px 16px 8px; text-align: center;">
<a href="${object.website_url}">
<img alt="${object.name}" src="${ctx['base_url']}/web/image/slide.slide/${object.id}/image" style="height:auto; width:150px; margin: 16px;"/>
......
......@@ -379,7 +379,10 @@ class Slide(models.Model):
mail_ids = []
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
for record in self:
mail_ids.append(self.channel_id.share_template_id.with_context(email=email, base_url=base_url).send_mail(record.id, notif_layout='mail.mail_notification_light'))
if self.env.user.has_group('base.group_portal'):
mail_ids.append(self.channel_id.share_template_id.with_context(user=self.env.user, email=email, base_url=base_url).sudo().send_mail(record.id, notif_layout='mail.mail_notification_light', email_values={'email_from': self.env['res.company'].catchall or self.env['res.company'].email}))
else:
mail_ids.append(self.channel_id.share_template_id.with_context(user=self.env.user, email=email, base_url=base_url).send_mail(record.id, notif_layout='mail.mail_notification_light'))
return mail_ids
def action_like(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment