Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
21396 Vistas

Hello,

I'm working on Employee directory module in Odoo 11 and I want to create a compute field that checks for each employee if its related user is equivalent to the current user (logged user).

I create the compute function but it allways return false.

Python code :

user_id = fields.Many2one('res.users', 'User', related='resource_id.user_id')
current_user = fields.Boolean('is current user ?', compute='_get_current_user')
@api.depends('user_id')def _get_current_user(self):
for in self:
  e.current_user = (self.env.user.id == e.user_id)

Any help, please ?

Avatar
Descartar
Mejor respuesta

Hello Mohamed,
You could try this

@api.one
@api.depends('user_id')
def _get_current_user(self):
self.current_user = (self.env.user.id == self.user_id.id)

current_user = fields.Boolean('is current user ?', compute='_get_current_user')
Avatar
Descartar
Mejor respuesta

In this post you will learn how to check login user group. The need of this post is, to sometime we need to visible invisible some filed on the basis of login user group or we want to perform some action on the basis of login user. To do so we need to get login user group.

There are two ways to do that:

Get complete code with description : http://learnopenerp.blogspot.com/2017/10/how-to-check-login-user-group-in-odoo.html

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
jul 24
1838
1
jun 24
4455
1
oct 23
10044
1
oct 23
98
1
ago 23
2193