Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
21998 Vizualizări

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 ?

Imagine profil
Abandonează
Cel mai bun răspuns

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')
Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
oct. 25
11508
2
iul. 24
3229
1
iun. 24
5592
1
oct. 23
98
1
aug. 23
2194