Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
5 Trả lời
7551 Lượt xem

I want to identify certain machines so that no matter which user is logged in some rules will apply to them. Is it possible?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

You can get the logged in machine details using the following code.

import httpagentparser

agent = request.httprequest.environ.get('HTTP_USER_AGENT')
agent_details = httpagentparser.detect(agent)
user_os = agent_details['os']['name']
browser_name = agent_details['browser']['name']
ip_address = request.httprequest.environ['REMOTE_ADDR']

From the above code you will get the IP address of the logged system, Browser and OS details.

You can also check with this community modules, but it is not in v7.

https://www.odoo.com/apps/modules/10.0/login_user_detail/

https://www.odoo.com/apps/modules/10.0/user_login_alert/

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

How do I get the request object?

above code is return inside the controller. You can check the modules in the given link, that will give you more info

Câu trả lời hay nhất

User login alert gives error as "Unable to install module "user_login_alert" because an external dependency is not met: No module named httpagentparser" Please assist.

Ảnh đại diện
Huỷ bỏ

`pip install httpagentparser` should solve your issue

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 3 24
11408
2
thg 8 21
13618
1
thg 12 19
5449
0
thg 9 17
3621
0
thg 8 17
2926