diff options
| author | Thibault Delavallée <tde@odoo.com> | 2016-09-15 11:22:53 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2016-09-23 10:01:04 +0200 |
| commit | a9bd9ab16087142e27076c63ef60a0467f0bcfad (patch) | |
| tree | fc6fb894cdb686ef50efd66a2ab8200ab98f8049 /addons/website_project_issue | |
| parent | 033fc508f4b6330cb1a8d25cfd75c103c648edbb (diff) | |
[FIX][IMP] various: unsudo mail/view controller and get_access_action
mail/view controller is a generic controller that redirects the user to a
given view, depending on the record and the user. Users may be redirected
to the backend form view, or to a website view. This is done notably by
calling get_access_action method that gives the action to perform (act_window
or url).
Previously this method was called using SUPERUSER. However it was therefore
impossible to know who the user was. This method is now called using the
current user. Various overrides of get_access_action have been updated to
add some logic and access rights check directly in the method allowing
more fine-grain behavior of the access action.
Diffstat (limited to 'addons/website_project_issue')
| -rw-r--r-- | addons/website_project_issue/models/project_issue.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/addons/website_project_issue/models/project_issue.py b/addons/website_project_issue/models/project_issue.py index 521b70c4398..3d89cad326b 100644 --- a/addons/website_project_issue/models/project_issue.py +++ b/addons/website_project_issue/models/project_issue.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, models +from odoo import api, exceptions, models class Issue(models.Model): @@ -10,15 +10,22 @@ class Issue(models.Model): @api.multi def get_access_action(self): - """ Override method that generated the link to access the document. Instead - of the classic form view, redirect to the post on the website directly """ + """ Instead of the classic form view, redirect to website for portal users + that can read the issue. """ self.ensure_one() - return { - 'type': 'ir.actions.act_url', - 'url': '/my/issues/%s' % self.id, - 'target': 'self', - 'res_id': self.id, - } + if self.env.user.share: + try: + self.check_access_rule('read') + except exceptions.AccessError: + pass + else: + return { + 'type': 'ir.actions.act_url', + 'url': '/my/issues/%s' % self.id, + 'target': 'self', + 'res_id': self.id, + } + return super(Issue, self).get_access_action() @api.multi def _notification_group_recipients(self, message, recipients, done_ids, group_data): |
