How to logout automatically when browser is closing.is there any options in odoo for this requirement?
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ờ
Hello, I will not post the easy sollution here but just an idea for solving.
As far as I know there is no config or switcher for this, so you need to implement this on your own. How?
Let's sum up what we know about session:
- Session in odoo is maintained (like almost in every online app) with session cookies
- Session cookies are specific - why?:
- by default if you will not set expiry date or "max_age" parameter while setting cookie it will exactly behave like you would like to exepct:
- whenever user closes the window/browser - cookie will be gone
- So the idea is to set the session cookie without this parameter or to change the cookies validity time. How? So lets check what's the cookie documentation says:
Set the cookie "Max-Age" attribute.
A positive value indicates when the cookie should expire relative to the current time. A value of 0 means the cookie should expire immediately. A negative value results in no "Max-Age" attribute in which case the cookie is removed when the browser is closed.
- So you need to set cookie without this parameter or even better with "-1" value - it will force the browser to delete the cookie immediately after it's closed - BINGO!
- So now what to do, and where to find it? I see you use Odoo 11
You must inherit the "def get_response" method from Root(object) - link below
github.com/odoo/odoo/blob/6a52d22c6f13dd8cd4a9e4b7cc424a1c47010f35/odoo/http.py#L1420 - Look at line 1427 - here you see setting the max_age parameter for session cookies
- Make your custom module inheriting the whole get_response (line 1392) and adjust line 1427 to your needs
for example like this:
if not explicit_session and hasattr(response, 'set_cookie'):
response.set_cookie('session_id', httprequest.session.sid, max_age=-1, httponly=True)
So I do not exactly know what is your knowledge, but assume you have dived into odoo development so far. So, please, take it easy with small steps and you will achieve your goal.
Good luck!
Hope it will help you anything.
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 10 20
|
9036 | ||
|
1
thg 3 18
|
7950 | ||
|
1
thg 3 23
|
6898 | ||
|
1
thg 4 22
|
3487 | ||
|
1
thg 11 22
|
3358 |