From 7fbdf2ae8d97380bbad32fc514b17392b4050e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Warnon?= Date: Mon, 5 Jun 2023 08:00:49 +0000 Subject: [PATCH] [FIX] website_slides: allow portal users to share slides by email MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sharing content by email as portal is not working and raises an AccessRecord because we are trying to access the "email_formatted" field of the company. This is solved by adding 'compute_sudo' to the computed field. Indeed, we want portal users to be able to read the email address of the company while they cannot access res.partner records. A tour has been adapted to ensure this behavior. Task-3349132 closes odoo/odoo#124036 X-original-commit: a37cea5af70728106445eac8dc0ccf7a95054501 Signed-off-by: Warnon Aurélien (awa) Signed-off-by: Thibault Delavallee (tde) --- addons/mail/models/res_company.py | 5 ++++- .../static/tests/tours/slides_course_member.js | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/res_company.py b/addons/mail/models/res_company.py index 3572c903d0e..fc21ad3616d 100644 --- a/addons/mail/models/res_company.py +++ b/addons/mail/models/res_company.py @@ -10,7 +10,10 @@ class Company(models.Model): catchall_email = fields.Char(string="Catchall Email", compute="_compute_catchall") catchall_formatted = fields.Char(string="Catchall", compute="_compute_catchall") - email_formatted = fields.Char(string="Formatted Email", compute="_compute_email_formatted") + # the compute method is sudo'ed because it needs to access res.partner records + # portal users cannot access those (but they should be able to read the company email address) + email_formatted = fields.Char(string="Formatted Email", + compute="_compute_email_formatted", compute_sudo=True) @api.depends('name') def _compute_catchall(self): diff --git a/addons/website_slides/static/tests/tours/slides_course_member.js b/addons/website_slides/static/tests/tours/slides_course_member.js index 9a207399e9f..534a635d656 100644 --- a/addons/website_slides/static/tests/tours/slides_course_member.js +++ b/addons/website_slides/static/tests/tours/slides_course_member.js @@ -31,6 +31,21 @@ registry.category("web_tour.tours").add('course_member', { trigger: '.o_wslides_fs_slide_name:contains("Home Gardening")', run: 'click', }, +// eLearning: share the first slide +{ + trigger: '.o_wslides_fs_share' +}, { + trigger: '.o_wslides_js_share_email input', + run: 'text friend@example.com' +}, { + trigger: '.o_wslides_js_share_email button', +}, { + trigger: '.o_wslides_js_share_email:contains("Sharing is caring")', + run: function () {} // check email has been sent +}, { + trigger: '.modal-footer button:contains("Close")', +}, +// eLeaning: course completion { trigger: '.o_wslides_fs_sidebar_header', run: function () {