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

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
مارس 24
11339
2
أغسطس 21
13555
1
ديسمبر 19
5398
0
سبتمبر 17
3540
0
أغسطس 17
2899