Search code examples
securityodoo-12

restrict access of tasks to assigned users only in odoo 12


I want to restrict access to assigned users in tasks. so, user can see only assigned tasks just now user can see all the tasks. I tried below thing but it's not working.

<record id="group_project_user_developer" model="res.groups">
            <field name="name">Developer</field>
            <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
            <field name="category_id" ref="base.module_category_project_management"/>
        </record>

        <record id="project.group_project_user" model="res.groups">
            <field name="name">User</field>
            <field name="implied_ids" eval="[(4, ref('project_custom.group_project_user_developer'))]"/>
            <field name="category_id" ref="base.module_category_project_management"/>
        </record>

        <record model="ir.rule" id="own_task_view_rule">
            <field name="name">See own tasks only</field>
            <field name="model_id" ref="project.model_project_task"/>
            <field name="groups" eval="[(4, ref('project_custom.group_project_user_developer'))]" />
            <field name="domain_force">[('user_id','=',user.id)]</field>
        </record>

Here user having Developer group can access all the tasks but in real it should allow to access only assigned tasks.


Solution

  • <delete model="ir.rule" id="project.task_visibility_rule"/> in Odoo 13 may have the same id in Odoo 12. This rule allows to show all projects task to the user regardless of your rule so to make your rule work you have to delete this one
    Delete or inactive this rule Delete the following rule or inactive it to check your code is working then add it via XML to delete with code also manager is allowed so your rights will only work if you set project task and fsm task = user in access rights
    If you are having a problem finding this rule just search this in codes XML files to find this rule

    follow required for follower-only projects

    This is the rule allow the manager to see all tasks enter image description here
    In general, there must be another rule that is allowing things that you may not be allowing so keep that in mind when your rule is not working