summaryrefslogtreecommitdiff
path: root/addons/website_project/models/project.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-09-30 17:23:30 +0200
committerChristophe Simonis <chs@odoo.com>2016-09-30 17:23:30 +0200
commitc8cc54559b75a621e4444ecdca6abd901b45e494 (patch)
tree92141325d4dbbf70bbfb8e0c040d4435c8d2378f /addons/website_project/models/project.py
parentb2804b1d2ae5fd7ec5c0eca79a8db77476badc84 (diff)
parent91a14488250bc2bb405cc6d300359aa272642484 (diff)
[MERGE] forward port branch 10.0 up to 91a1448
Diffstat (limited to 'addons/website_project/models/project.py')
-rw-r--r--addons/website_project/models/project.py79
1 files changed, 44 insertions, 35 deletions
diff --git a/addons/website_project/models/project.py b/addons/website_project/models/project.py
index e44a9f5f131..450e9de178d 100644
--- a/addons/website_project/models/project.py
+++ b/addons/website_project/models/project.py
@@ -1,33 +1,38 @@
# -*- 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 Project(models.Model):
_inherit = ['project.project']
@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 project. """
self.ensure_one()
- return {
- 'type': 'ir.actions.act_url',
- 'url': '/my/project/%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/project/%s' % self.id,
+ 'target': 'self',
+ 'res_id': self.id,
+ }
+ return super(Project, self).get_access_action()
@api.multi
- def _notification_group_recipients(self, message, recipients, done_ids, group_data):
- """ Override the method to place the portal customers in the 'user' group data as a portal view now exists"""
- for recipient in recipients:
- if recipient.id in done_ids:
- continue
- if recipient.user_ids and all(recipient.user_ids.mapped('share')):
- group_data['user'] |= recipient
- done_ids.add(recipient.id)
- return super(Project, self)._notification_group_recipients(message, recipients, done_ids, group_data)
+ def _notification_recipients(self, message, groups):
+ groups = super(Project, self)._notification_recipients(message, groups)
+
+ for group_name, group_method, group_data in groups:
+ group_data['has_button_access'] = True
+
+ return groups
class Task(models.Model):
@@ -35,24 +40,28 @@ class Task(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 task. """
self.ensure_one()
- return {
- 'type': 'ir.actions.act_url',
- 'url': '/my/task/%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/task/%s' % self.id,
+ 'target': 'self',
+ 'res_id': self.id,
+ }
+ return super(Task, self).get_access_action()
@api.multi
- def _notification_group_recipients(self, message, recipients, done_ids, group_data):
- """ Override the method to place the portal customers in the 'user' group data as a portal view now exists"""
- for recipient in recipients:
- if recipient.id in done_ids:
- continue
- if recipient.user_ids and all(recipient.user_ids.mapped('share')):
- group_data['user'] |= recipient
- done_ids.add(recipient.id)
- return super(Task, self)._notification_group_recipients(message, recipients, done_ids, group_data)
+ def _notification_recipients(self, message, groups):
+ groups = super(Task, self)._notification_recipients(message, groups)
+
+ for group_name, group_method, group_data in groups:
+ group_data['has_button_access'] = True
+ return groups