summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Hoste <pko@odoo.com>2019-06-19 11:48:19 +0000
committerPatrick Hoste <pko@odoo.com>2019-06-19 11:50:33 +0000
commitbe5e8fdab800ff1fd9e953ec64801f96bcc3dac5 (patch)
tree3c8d5d11f13592140bbf98be727359ac2782ab95
parentf3b6ff0c192daa11c15c1834a898287616b6f965 (diff)
[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: Thibault Delavallee (tde) <tde@openerp.com>
-rw-r--r--addons/website_slides/data/mail_data.xml6
-rw-r--r--addons/website_slides/models/slide_slide.py5
2 files changed, 7 insertions, 4 deletions
diff --git a/addons/website_slides/data/mail_data.xml b/addons/website_slides/data/mail_data.xml
index 3b397545940..fe5d8f800a4 100644
--- a/addons/website_slides/data/mail_data.xml
+++ b/addons/website_slides/data/mail_data.xml
@@ -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;"/>
diff --git a/addons/website_slides/models/slide_slide.py b/addons/website_slides/models/slide_slide.py
index df7d1c079b6..71a8207025a 100644
--- a/addons/website_slides/models/slide_slide.py
+++ b/addons/website_slides/models/slide_slide.py
@@ -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):