iam logged in some user like johnsmith. so here how to print current logged user name. how it's done in odoo v8?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Try the following:
self.env.user.name
current user is nothing but uid in python code Eg
def buttton_click(cr,uid,ids,context=None):
rec=self.pool.get('res.user').browse(cr,uid,uid)
print rec.login
but browse pass only the list of id's. i dnt know current user id. In this case how i retrieve?
that uid is the id we should pass.. just try it u will get to know..
This little function will get you the username you're logged in with:
def _get_user_name(self, cr, uid, *args):
user_obj = self.pool.get('res.users')
user_value = user_obj.browse(cr, uid, uid)
return user_value.login or False
And you can then call it from Python code and do with it whatever you want. For example to print it in a field as default value:
defaults = {
'username_print': _get_user_name,
}
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
2
thg 8 24
|
1711 | ||
|
2
thg 6 22
|
3760 | ||
how to get the logged user
Đã xử lý
|
|
2
thg 2 24
|
14491 | |
|
1
thg 9 19
|
6180 | ||
|
1
thg 4 17
|
5569 |