跳至内容
菜单
此问题已终结

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


形象
丢弃
最佳答案

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

   

形象
丢弃
编写者

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

相关帖文 回复 查看 活动
0
6月 24
1302
3
5月 24
5769
4
11月 23
2546
1
10月 21
1984
0
8月 21
3259