Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Access rule now applies correctly to followers #93

Open
wants to merge 1 commit into
base: 9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project_task_activity/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
##############################################################################
{
"name": "Project Task Activity",
'version': '9.0.1.0.0',
'version': '9.0.1.0.1',
'category': 'Tools',
'sequence': 14,
'author': 'ADHOC SA',
Expand Down
46 changes: 45 additions & 1 deletion project_task_activity/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# For copyright and license notices, see __openerp__.py file in module root
# directory
##############################################################################
from openerp import models, api, fields, _
from openerp import models, api, fields, _, SUPERUSER_ID
from datetime import datetime
# import json

Expand Down Expand Up @@ -58,6 +58,28 @@ class ProjectTask(models.Model):
activities_total = fields.Char(
string="Activities Total",
compute='_get_activities_total')
message_partner_ids = fields.Many2many(
'res.partner',
'task_msg_partner_rel',
'msg_id',
'partner_id',
compute='_compute_following_partners'
)

@api.multi
@api.depends('message_follower_ids')
def _compute_following_partners(self):
for task in self:
task.message_partner_ids = [
(6, False, [
x.id for x in task.message_follower_ids.mapped('partner_id')
])
]

def init(self, cr):
ids = self.search(cr, SUPERUSER_ID, [])
for task in self.browse(cr, SUPERUSER_ID, ids):
task._compute_following_partners()

@api.one
@api.depends('activity_ids.state')
Expand Down Expand Up @@ -91,6 +113,28 @@ class ProjectProject(models.Model):
progress_activities = fields.Float(
string=_("Progress"),
compute='_get_progress_activities')
message_partner_ids = fields.Many2many(
'res.partner',
'project_msg_partner_rel',
'msg_id',
'partner_id',
compute='_compute_following_partners'
)

@api.multi
@api.depends('message_follower_ids')
def _compute_following_partners(self):
for project in self:
project.message_partner_ids = [
(6, False, [
x.id for x in project.message_follower_ids.mapped('partner_id')
])
]

def init(self, cr):
ids = self.search(cr, SUPERUSER_ID, [])
for project in self.browse(cr, SUPERUSER_ID, ids):
project._compute_following_partners()

@api.one
def _get_task_activity(self):
Expand Down
4 changes: 2 additions & 2 deletions project_task_activity/security/project_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
'|',
'&',
('project_id.privacy_visibility', '=', 'followers'),
('project_id.message_follower_ids', 'in', [user.partner_id.id]),
('project_id.message_partner_ids', 'in', [user.partner_id.id]),
'|',
('task_id.message_follower_ids', 'in', [user.partner_id.id]),
('task_id.message_partner_ids', 'in', [user.partner_id.id]),
# to subscribe check access to the record, follower is not enough at creation
('user_id', '=', user.id)
]</field>
Expand Down