Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3585 Vistas

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
Descartar
Mejor respuesta

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

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

Publicaciones relacionadas Respuestas Vistas Actividad
0
jun 24
1444
3
may 24
6003
4
nov 23
2755
1
oct 21
2129
0
ago 21
3397