도움말

0

How to name a certain model as domain condition for record rule

Avatar
Jeff

Hi, 


I'm trying to limit mymodel's access privilege by using a more complicate condition not just `user.id`. The condition comes from a customized model, my thinking is access env to grab the model, but it tells me "name 'self' is not defined". This is my code below, I want to know what is the collect way to access a model within domain_force expression?

<field name="domain_force">
[( 'payee_id', 'in', [ self.env['mymodel.payee'].search([('user_id', '=', user.id)]).id ] )]
</field>


Thanks


Jeff


Avatar
Discard
1 응답
0
Best Answer

Hello Jeff,

First thing is self is not available in xml files 

So try env[].search


But if it still not work for you then follow the best way to define one compute M2M field and record all the payee ids in it and simple check 


<field name="domain_force">

    [( 'payee_id', 'in', M2M_FIELD_NAME.ids] )]

</field>


Regards,




Email:   odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

2 의견
Avatar
Discard
Avatar
Jeff
-

Thank you for responding my question, unfortunately this approaching gave same error as "name 'M2M_FIELD_NAME' is not defined" while evaluating". How to let odoo recognizes my customized stuff as condition , that's the problem.

Try this it will work

<field name="domain_force">

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

</field>

And if you still getting error after this please provide more details