Odoo Help

0

How can I restrict access to project phases for project managers that haven't created that project?

By
Bill Ennals
on 4/1/14, 1:10 AM 2,010 views

By default, Project Managers can see project phases of all projects, even if they didn't create or aren't following the projects. I've tried using the following record rule:

['|',('user_id','=',False),('user_id','=',user.id)]

and applying it to the object 'project.phase' to limit read access to projects that they associated with, but doing so gives me the following error when I click on either the Project/Project or Project/Project Phases menu items:

raise ValueError("Invalid field %r in leaf %r" % (left, str(leaf))) ValueError: Invalid field 'user_id' in leaf "<osv.extendedleaf: ('user_id',="" '=", False) on project_phase (ctx: )&gt;"&lt;/p&gt; &lt;p&gt;Is their some way to change this record rule so that it allows Project Managers to see phases of projects that they are associated with but not projects they have nothing to do with&lt;/p&gt; ">

1
Med Said BARA
On 4/1/14, 9:48 AM

Hi,

Maybe, you could find some help here.

Thanks for the reply, but that's not exactly what I'm looking for. I think I've actually figured it out. See my answer below.

Bill Ennals
on 4/1/14, 7:18 PM
0
Bill Ennals
On 4/1/14, 8:09 PM

The answer appears to be this:

I looked at the error again (Invalid field 'user_id' in leaf ) and wondered if that meant that the "user_id" was not actually contained in or referenced by the project.phase object. I looked at the existing record rule for tasks, 'Tasks According to User and Project', and noticed that it seemed to restrict users from seeing other users tasks but also had a part that seemed to permit them to see tasks that were associated with projects they were associated with, even if the tasks were not assigned to them directly.

This is the rule:

['|','|','|',('user_id','=',False),('user_id','=',user.id),('project_id.members','in', [user.id]),('project_id.user_id','=',user.id)]

So, I tried removing the user_id section and changed it to this:

['|',('project_id.members','in', [user.id]),('project_id.user_id','=',user.id)]

I added the group 'Project Managers', saved the record rule, and hey presto, it worked. Now Project Managers can only see phases from projects that they are associated with.

Not bad for someone who knows nothing about coding!

Bill.

edited to remove suggestion that this would work for project.project. Doing so causes an invalid field error on 'project_id.members'.

BRAVO, Good job.

Med Said BARA
on 4/1/14, 8:40 PM

If we will not select any group and keep it global I think that will be great?

dirtyHandsPHP
on 4/25/14, 9:28 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 4/1/14, 1:10 AM
Seen: 2010 times
Last updated: 3/16/15, 8:10 AM