Skip to content
Snippets Groups Projects
Commit d341efaf authored by Nasreddin Boulif (bon)'s avatar Nasreddin Boulif (bon)
Browse files

[FIX] website_slides: Raise error if not responsible on invite


Steps to reproduce:

- Install `E-learning` module
- Create a user X with only "Officer" as rights for `E-learning`
- Login with user X
- Go to `E-learning` and open any course
- Ensure that the user X is not the responsible and that the course
  enroll policy is set to "On invitation"
- Invite any user not already a member

Issue:

  No user was invited (not added as member) and no warning message
  raised.

Cause:

  Due to the ir.rule "Channel: officer: create/write own only", the
  `Officer` user can only edit (and therefore invite members) on
  courses where he is responsible.

Solution:

  Add a context key to the 'Invite' buttons in the `Form` and `Kanban`
  views of `slide.channel` model so that we can raise an error only in
  these flows if the user does not have the rights to invite members.

opw-3133733

closes odoo/odoo#111642

Signed-off-by: default avatarWarnon Aurélien (awa) <awa@odoo.com>
parent 32aca111
No related branches found
No related tags found
No related merge requests found
...@@ -5150,6 +5150,14 @@ msgstr "" ...@@ -5150,6 +5150,14 @@ msgstr ""
msgid "Yes" msgid "Yes"
msgstr "" msgstr ""
#. module: website_slides
#: code:addons/website_slides/wizard/slide_channel_invite.py:0
#, python-format
msgid ""
"You are not allowed to add members to this course. Please contact the course"
" responsible or an administrator."
msgstr ""
#. module: website_slides #. module: website_slides
#. openerp-web #. openerp-web
#: code:addons/website_slides/static/src/js/tours/slides_tour.js:0 #: code:addons/website_slides/static/src/js/tours/slides_tour.js:0
......
...@@ -5,7 +5,7 @@ import logging ...@@ -5,7 +5,7 @@ import logging
import re import re
from odoo import api, fields, models, _ from odoo import api, fields, models, _
from odoo.exceptions import UserError from odoo.exceptions import UserError, AccessError
from odoo.tools import formataddr from odoo.tools import formataddr
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
...@@ -78,6 +78,12 @@ class SlideChannelInvite(models.TransientModel): ...@@ -78,6 +78,12 @@ class SlideChannelInvite(models.TransientModel):
if not self.env.user.email: if not self.env.user.email:
raise UserError(_("Unable to post message, please configure the sender's email address.")) raise UserError(_("Unable to post message, please configure the sender's email address."))
try:
self.channel_id.check_access_rights('write')
self.channel_id.check_access_rule('write')
except AccessError:
raise AccessError(_('You are not allowed to add members to this course. Please contact the course responsible or an administrator.'))
mail_values = [] mail_values = []
for partner_id in self.partner_ids: for partner_id in self.partner_ids:
slide_channel_partner = self.channel_id._action_add_members(partner_id) slide_channel_partner = self.channel_id._action_add_members(partner_id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment