[FIX] website_slides: allow portal users to share slides by email

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) <awa@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Aurélien Warnon
2023-06-07 08:59:18 +02:00
parent 335dd9a1e4
commit 7fbdf2ae8d
2 changed files with 19 additions and 1 deletions
+4 -1
View File
@@ -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):
@@ -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 () {