تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
21988 أدوات العرض

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 ?

الصورة الرمزية
إهمال
أفضل إجابة

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')
الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
أكتوبر 25
11497
2
يوليو 24
3229
1
يونيو 24
5579
1
أكتوبر 23
98
1
أغسطس 23
2194