Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
21983 Widoki

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 ?

Awatar
Odrzuć
Najlepsza odpowiedź

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')
Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
lip 24
3228
1
cze 24
5577
1
paź 23
11449
1
paź 23
98
1
sie 23
2194