Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
3594 Visualizações

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
Cancelar
Melhor resposta

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

Publicações relacionadas Respostas Visualizações Atividade
0
jun. 24
1468
3
mai. 24
6015
4
nov. 23
2772
1
out. 21
2148
0
ago. 21
3401