How can I add group rules for users?

122 Views Asked by At

I have added group rules for users that the users can only see their own data but I am facing an error. I have written the following code:

 <record id="memes_member_user_rule" model="ir.rule">
            <field name="name">For Users</field>
            <field name="model_id" ref="model_memes_member"/>
            <field name="global" eval="False"/>
            <field name="domain_force">[('parent_id.user_id','=',user.id)]</field>
            <field name="groups" eval="[(4, ref('memes.group_memes_user'))]"/>
        </record>

I am facing the following error:

 raise AttributeError(name)
AttributeError: auto_join
1

There are 1 best solutions below

0
On BEST ANSWER

I think that your problem is the group name. I think you don´t have to add the ´memes.´ try to keep just ´group_memes_user´.

I am working on group rules also. The code I am using is almost the same as you:

<record id="cms_user_rule" model="ir.rule">
                <field name="name">MultiCompany - Admin</field>
                <field name="model_id" ref="model_cms_ci_cicore"/>
                <field name="perm_read" eval="True"/>
                <field name="perm_create" eval="True"/>
                <field name="perm_write" eval="True"/>
                <field name="perm_unlink" eval="True"/>
                <field name="groups" eval="[(4, ref('group_cms_user'))]"/>
                <field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', user.company_ids.ids)]</field>
</record>

The other differences are that I didn't set global false and the order of groups and domain_force.