From 8c31d9772afee8c8fed430fd84c53c6e930fbadd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 26 Apr 2013 15:02:59 +0200 Subject: [PATCH 1/2] [FIX] project, task, issue, portal: fixed access rules for employees/portal users + added an help on privacy_visibility. bzr revid: tde@openerp.com-20130426130259-35j0v7lg7unxhzzp --- .../security/portal_security.xml | 27 ++++++++--------- .../security/portal_security.xml | 30 +++++++++---------- .../security/portal_security.xml | 15 +++++----- addons/project/project.py | 14 +++++++-- addons/project/security/project_security.xml | 12 ++++---- .../security/project_issue_security.xml | 12 ++++---- 6 files changed, 58 insertions(+), 52 deletions(-) diff --git a/addons/portal_project/security/portal_security.xml b/addons/portal_project/security/portal_security.xml index 8d58ed70aeb..67e57766ebd 100644 --- a/addons/portal_project/security/portal_security.xml +++ b/addons/portal_project/security/portal_security.xml @@ -33,27 +33,26 @@ - Project/Task: employees: public, portal, employee or following or assigned + Project/Task: employees: public, portal, employee or (followers and following) ['|', - ('user_id', '=', user.id), - '|', - ('project_id.privacy_visibility', 'in', ['public', 'portal', 'employees']), - '&', - ('project_id.privacy_visibility', '=', 'followers'), - ('message_follower_ids', 'in', [user.partner_id.id]), + ('project_id.privacy_visibility', 'in', ['public', 'portal', 'employees']), + '&', + ('project_id.privacy_visibility', '=', 'followers'), + ('message_follower_ids', 'in', [user.partner_id.id]), ] - Project/Task: portal users: public or portal and following + Project/Task: portal users: public or (portal and colleagues following) or (followers and following) - ['|', - ('project_id.privacy_visibility', '=', 'public'), + ['|', '|', + ('project_id.privacy_visibility', 'in', ['public']), '&', - ('project_id.privacy_visibility', 'in', ['portal', 'followers']), - '|', - ('message_follower_ids','in', [user.partner_id.id]), - ('user_id', '=', user.id), + ('project_id.privacy_visibility', '=', 'portal'), + ('message_follower_ids', 'child_of', [user.partner_id.commercial_partner_id.id]), + '&', + ('project_id.privacy_visibility', '=', 'followers'), + ('message_follower_ids', 'in', [user.partner_id.id]), ] diff --git a/addons/portal_project_issue/security/portal_security.xml b/addons/portal_project_issue/security/portal_security.xml index 120611cec0e..598c1620a82 100644 --- a/addons/portal_project_issue/security/portal_security.xml +++ b/addons/portal_project_issue/security/portal_security.xml @@ -3,27 +3,27 @@ - Project/Issue: portal users: public or portal and following + Project/Issue: portal users: public or (portal and colleagues following) or (followers and following) - [ '&', - ('project_id.privacy_visibility', 'in', ['public', 'portal', 'followers']), - '|', '|', - ('message_follower_ids','in', [user.partner_id.id]), - ('user_id', '=', user.id), - ('partner_id', 'child_of', [user.commercial_partner_id.id]) - ] + ['|', '|', + ('project_id.privacy_visibility', 'in', ['public']), + '&', + ('project_id.privacy_visibility', '=', 'portal'), + ('message_follower_ids', 'child_of', [user.partner_id.commercial_partner_id.id]), + '&', + ('project_id.privacy_visibility', '=', 'followers'), + ('message_follower_ids', 'in', [user.partner_id.id]), + ] - Project/Issue: employees: public, portal, employee or following or assigned + Project/Issue: employees: public, portal, employee or (followers and following) ['|', - ('user_id', '=', user.id), - '|', - ('project_id.privacy_visibility', 'in', ['public', 'portal', 'employees']), - '&', - ('project_id.privacy_visibility', '=', 'followers'), - ('message_follower_ids', 'in', [user.partner_id.id]), + ('project_id.privacy_visibility', 'in', ['public', 'portal', 'employees']), + '&', + ('project_id.privacy_visibility', '=', 'followers'), + ('message_follower_ids', 'in', [user.partner_id.id]), ] diff --git a/addons/portal_project_long_term/security/portal_security.xml b/addons/portal_project_long_term/security/portal_security.xml index eab70ebe734..2a2f6f2fea1 100644 --- a/addons/portal_project_long_term/security/portal_security.xml +++ b/addons/portal_project_long_term/security/portal_security.xml @@ -3,15 +3,16 @@ - Project/Phase: portal users: public or portal and following + Project/Phase: portal users: public or (portal and colleagues following) or (followers and following) - ['|', - ('project_id.privacy_visibility', '=', 'public'), + ['|', '|', + ('project_id.privacy_visibility', 'in', ['public']), '&', - ('project_id.privacy_visibility', 'in', ['portal', 'followers']), - '|', - ('message_follower_ids','in', [user.partner_id.id]), - ('user_id', '=', user.id), + ('project_id.privacy_visibility', '=', 'portal'), + ('message_follower_ids', 'child_of', [user.partner_id.commercial_partner_id.id]), + '&', + ('project_id.privacy_visibility', '=', 'followers'), + ('message_follower_ids', '=', [user.partner_id.id]), ] diff --git a/addons/project/project.py b/addons/project/project.py index 0b99356a9de..f2d80a8ef22 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -210,7 +210,7 @@ class project(osv.osv): def _get_visibility_selection(self, cr, uid, context=None): """ Overriden in portal_project to offer more options """ - return [('public', 'All Users'), + return [('public', 'Public'), ('employees', 'Employees Only'), ('followers', 'Followers Only')] @@ -275,7 +275,17 @@ class project(osv.osv): "with Tasks (or optionally Issues if the Issue Tracker module is installed)."), 'alias_model': fields.selection(_alias_models, "Alias Model", select=True, required=True, help="The kind of document created when an email is received on this project's email alias"), - 'privacy_visibility': fields.selection(_visibility_selection, 'Privacy / Visibility', required=True), + 'privacy_visibility': fields.selection(_visibility_selection, 'Privacy / Visibility', required=True, + help="Holds visibility of the tasks or issues that belong to the current project:\n" + "- Public: everybody sees everything; if portal is activated, portal users\n" + " see all tasks or issues; if anonymous portal is activated, visitors\n" + " see all tasks or issues\n" + "- Portal (only available if Portal is installed): employees see everything;\n" + " if portal is activated, portal users see the tasks or issues followed by\n" + " them or by someone of their company\n" + "- Employees Only: employees see all tasks or issues\n" + "- Followers Only: employees see only the followed tasks or issues; if portal\n" + " is activated, portal users see the followed tasks or issues."), 'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','Pending'),('close','Closed')], 'Status', required=True,), 'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int') } diff --git a/addons/project/security/project_security.xml b/addons/project/security/project_security.xml index 4bbaa9b788e..e674019443b 100644 --- a/addons/project/security/project_security.xml +++ b/addons/project/security/project_security.xml @@ -75,15 +75,13 @@ - Project/Task: employees: public or employee or following or assigned + Project/Task: employees: public or employee or (followers and following) ['|', - ('user_id', '=', user.id), - '|', - ('project_id.privacy_visibility', 'in', ['public', 'employees']), - '&', - ('project_id.privacy_visibility', '=', 'followers'), - ('message_follower_ids', 'in', [user.partner_id.id]), + ('project_id.privacy_visibility', 'in', ['public', 'employees']), + '&', + ('project_id.privacy_visibility', '=', 'followers'), + ('message_follower_ids', 'in', [user.partner_id.id]), ] diff --git a/addons/project_issue/security/project_issue_security.xml b/addons/project_issue/security/project_issue_security.xml index 5215a94a8b7..c8ed12086e4 100644 --- a/addons/project_issue/security/project_issue_security.xml +++ b/addons/project_issue/security/project_issue_security.xml @@ -10,15 +10,13 @@ - Project/Issue: employees: public or employee or following or assigned + Project/Issue: employees: public or employee or (followers and following) ['|', - '|', - ('project_id.privacy_visibility', 'in', ['public', 'employees']), - '&', - ('project_id.privacy_visibility', '=', 'followers'), - ('message_follower_ids', 'in', [user.id]), - ('user_id', '=', user.id), + ('project_id.privacy_visibility', 'in', ['public', 'employees']), + '&', + ('project_id.privacy_visibility', '=', 'followers'), + ('message_follower_ids', 'in', [user.id]), ] From 2a4b097ef8403c100ae66eb6e538954085a845bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 26 Apr 2013 16:23:04 +0200 Subject: [PATCH 2/2] [FIX] portal_project_long_term: wrong ir_rule for project long term bzr revid: tde@openerp.com-20130426142304-fucpx510gj7v7t90 --- .../security/portal_security.xml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/addons/portal_project_long_term/security/portal_security.xml b/addons/portal_project_long_term/security/portal_security.xml index 2a2f6f2fea1..d8aec542847 100644 --- a/addons/portal_project_long_term/security/portal_security.xml +++ b/addons/portal_project_long_term/security/portal_security.xml @@ -5,15 +5,7 @@ Project/Phase: portal users: public or (portal and colleagues following) or (followers and following) - ['|', '|', - ('project_id.privacy_visibility', 'in', ['public']), - '&', - ('project_id.privacy_visibility', '=', 'portal'), - ('message_follower_ids', 'child_of', [user.partner_id.commercial_partner_id.id]), - '&', - ('project_id.privacy_visibility', '=', 'followers'), - ('message_follower_ids', '=', [user.partner_id.id]), - ] + [('project_id.privacy_visibility', 'in', ['public', 'portal'])]