diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py index 7fd5592fa66..4fe78246ec5 100644 --- a/addons/mail/controllers/main.py +++ b/addons/mail/controllers/main.py @@ -66,10 +66,15 @@ class MailController(http.Controller): # record does not seem to exist -> redirect to login return cls._redirect_to_messaging() record_action = record_sudo.get_access_action() + record_target_type = record_action.pop('target_type', 'dummy') - # the record has an URL redirection: use it directly + # the record has a public URL redirection: use it directly if record_action['type'] == 'ir.actions.act_url': - return werkzeug.utils.redirect(record_action['url']) + if record_target_type == 'public' and not uid: + return werkzeug.utils.redirect(record_action['url']) + else: + # user connected or non-public URL, handled below + pass # other choice: act_window (no support of anything else currently) elif not record_action['type'] == 'ir.actions.act_window': return cls._redirect_to_messaging() @@ -83,6 +88,9 @@ class MailController(http.Controller): except AccessError: return cls._redirect_to_messaging() + if record_action['type'] == 'ir.actions.act_url': + return werkzeug.utils.redirect(record_action['url']) + url_params = { 'view_type': record_action['view_type'], 'model': model, diff --git a/addons/website_blog/models/website_blog.py b/addons/website_blog/models/website_blog.py index d2af0807e6e..60ef917b695 100644 --- a/addons/website_blog/models/website_blog.py +++ b/addons/website_blog/models/website_blog.py @@ -226,6 +226,7 @@ class BlogPost(models.Model): 'type': 'ir.actions.act_url', 'url': '/blog/%s/post/%s' % (self.blog_id.id, self.id), 'target': 'self', + 'target_type': 'public', 'res_id': self.id, } diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 0820b67c80f..478c211634a 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -786,6 +786,7 @@ class Post(models.Model): 'type': 'ir.actions.act_url', 'url': '/forum/%s/question/%s' % (self.forum_id.id, self.id), 'target': 'self', + 'target_type': 'public', 'res_id': self.id, } diff --git a/addons/website_slides/models/slides.py b/addons/website_slides/models/slides.py index 6ac8c302754..363a28a7690 100644 --- a/addons/website_slides/models/slides.py +++ b/addons/website_slides/models/slides.py @@ -450,6 +450,7 @@ class Slide(models.Model): 'type': 'ir.actions.act_url', 'url': '%s' % self.website_url, 'target': 'self', + 'target_type': 'public', 'res_id': self.id, } return super(Slide, self).get_access_action()