Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
7583 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
ผู้เขียน

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

คำตอบที่ดีที่สุด

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.

อวตาร
ละทิ้ง

`pip install httpagentparser` should solve your issue

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
มี.ค. 24
11497
Dynamically created filter for tree view แก้ไขแล้ว
2
ส.ค. 21
13639
1
ธ.ค. 19
5483
0
ก.ย. 17
3629
0
ส.ค. 17
2938