This question has been flagged
3 Replies
2510 Views

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
Avatar
Discard

Please post full traceback error.

Best Answer

Hello Hammad,
you are facing this error because you implemented wrong values for "domain_force" , to correct it modify your code by replacing this

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

I hope this Information will be Helpful,
Feel free for further assistance on contact@geminatecs.com
Thank you,
Geminate Consultancy Services
w : www.geminatecs.com


Avatar
Discard
Best Answer

To fix this error, you need to add the "auto_join" attribute with a value of either True or False to your code. Here's an example of how you can modify your code to include the "auto_join" attribute:


In this example, I set the value of "auto_join" to False, but you can adjust it according to your specific requirements.

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

Avatar
Discard
Best Answer

Hi

You can try this method for applying rules,

<record id="your_rule_id" model="ir.rule">
        <field name="name">Rule Name</field>
        <field name="model_id" ref="model_<model_name>"/>
        <field name="domain_force">[('user_id', '=', user.id)]</field>
 
      <field name="groups" eval="[(4, ref('module_name.user_group_id'))]"
</record>

Hope it helps

Avatar
Discard