From 4c692f1bb31766840ca3eca6a8e0faebd34cda1a Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 20 Mar 2018 08:45:52 +0100 Subject: [PATCH] [FIX] website_project{_issue}: redirect from email - Create a portal user - Set an email address - Create a project with tasks / issues - Create a task / issue, set the portal user as follower => he should have access to the task from URL `/my/task/`. - On an email received (e.g. when the user is set as follower), click on 'View Task' The user is redirected to the chatter instead of `/my/task/` or `/my/issue/`. In method, `_redirect_to_record`, the record is browsed as `sudo`. Therefore, in `get_access_action`, `self.env.user` is the admin. We check the context to get the original user. opw-1814577 --- addons/website_project/models/project.py | 12 ++++++++++-- addons/website_project_issue/models/project_issue.py | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/addons/website_project/models/project.py b/addons/website_project/models/project.py index 450e9de178d..3cf861e68d5 100644 --- a/addons/website_project/models/project.py +++ b/addons/website_project/models/project.py @@ -11,7 +11,11 @@ class Project(models.Model): """ Instead of the classic form view, redirect to website for portal users that can read the project. """ self.ensure_one() - if self.env.user.share: + if self.env.context.get('uid'): + user = self.env['res.users'].browse(self.env.context['uid']) + else: + user = self.env.user + if user.share: try: self.check_access_rule('read') except exceptions.AccessError: @@ -43,7 +47,11 @@ class Task(models.Model): """ Instead of the classic form view, redirect to website for portal users that can read the task. """ self.ensure_one() - if self.env.user.share: + if self.env.context.get('uid'): + user = self.env['res.users'].browse(self.env.context['uid']) + else: + user = self.env.user + if user.share: try: self.check_access_rule('read') except exceptions.AccessError: diff --git a/addons/website_project_issue/models/project_issue.py b/addons/website_project_issue/models/project_issue.py index d6d8916026a..ed5421924b5 100644 --- a/addons/website_project_issue/models/project_issue.py +++ b/addons/website_project_issue/models/project_issue.py @@ -13,7 +13,11 @@ class Issue(models.Model): """ Instead of the classic form view, redirect to website for portal users that can read the issue. """ self.ensure_one() - if self.env.user.share: + if self.env.context.get('uid'): + user = self.env['res.users'].browse(self.env.context['uid']) + else: + user = self.env.user + if user.share: try: self.check_access_rule('read') except exceptions.AccessError: