Skip to Content
Menu
This question has been flagged

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

   

Avatar
Discard
Author

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

Related Posts Replies Views Activity
0
Jun 24
348
3
May 24
4128
4
Nov 23
977
1
Oct 21
1029
0
Aug 21
2411