Skip to Content
Menu
This question has been flagged
8 Replies
8896 Views

Hi all,

I want to implement automatically signout feature from HR module in odoo 8 or openerp 7 version.

Currently the attendance system shows last sign in message and click for signout and sign in alert .But I want to do signout steps automatically ,if the user is in idle(sleep ,based on our PC) condition for a particular time period.How can I achievee this task? 

Avatar
Discard
Best Answer

You can install the community addon: Idle Logout

Avatar
Discard
Author

Hi..Appreciate for your response.But actual requirement is related to HR Employees ,not for users in odoo.. I can easily customize users Logout by http.py file.But my question is related to hr employees sign out if the PC is idle some time...Please replay for this question..

Best Answer


the same function is available in odoo 8. The only difference is that the http.py file is located at the root of odoo directory and not in addons/web . One more thing. If you server doesnt have a heavy request, it could be better for you to increase the top limit of the random value : for example

if random.random() < 0.1:

This is valid for session timeout from the server and not from HR module

To automaticaly sign out of HR attendance, this is one of the steps you can do:

1. Create a module that depends on hr.attendance

2. inherit the hr.employee class

3. define a function that you can call in an action. this function is in the new hr_employe class you created

4. Inside the function, for each employee (hr.employee) define a routine to check if the session is active for the user (res.user) related to the employee (it can be similar to the function in http.py session_gc(session_store) without the random ). dont forget to import packages like os, sys

5. When the user has no active session, if employee.state=='present', call attendance_action_change(cr, employee.id, [], context=None) . This function is already defined in the hr.employee under hr.attendance module

6. Create an action that you can call, lets say every 5 min. Bind it on the hr.employee object with the function you created on step 3



Avatar
Discard
Author

Then how to implement this in odoo 8,Can you explain step by step

You mean for the HR attendance Signout? If yes then one of the things to to could be 1. Create a module that depends on hr.attendance 2. inherit the hr.employee class 3. define a function that you can call in an action. this function is in the new hr_employe class you created 4. Inside the function, for each employe define a routine to check if the session is active for a user (it can be similar to the function in http.py session_gc(session_store) without the random ) 5. When the session is not active, if employee.state=='present', call attendance_action_change(cr, employee.id, [], context=None) . This function is defined in the hr.employee under hr.attendance module 6. Create an action that you can call, lets say every 5 min. Bind it on the hr.employee object with the function you created on step 3

Best Answer

Signout or Logout, a little bit confused: login (logon) and logout (logoff) or sign in sign out ...... OpenERP Session or HR Time and Attendance !!! ???

In your question you are talking about 2 different things: OpenERP automatic Logout from session (based on timeout) and  HR Attendance Signout.

For the first case, if you just want to log out user (ending his session): edit the file ../addons/web/http.py at line 450 (last_week = time.time() - 60*60*24*7), and replace 60*60*24*24*7 by the value you want (Idle Time = Timeout - in seconds )  (e.g for 15 minutes = 60*15, for one day = 60*60*24, for 2 days = 60*60*24*2 ...). And restart the server if needed.

For the second case, just post another question, describing what you really want.

And if you want to implement an automatic sign out solution for Time tracking in HR Attendance (an employee forgot to sign out ...)  just take a look to the code in this module (or use it as it is).

Important Remark: When a user is Login out from his session this not mean that he Signed out for the Day in Attendance.

Very complicated solution, you are putting the bar very high !!!

In fact you need a mix of the both cases, maybe this can simply done by executing the hr_sign_out_forgotten_solve when removing session (i mean calling the function hr_sign_out_forgotten_solve ​in the removed_sessions) BUT HOW ???And this implies that the employee is already in Sign in State.

Avatar
Discard
Author

Yes I need the second case HR Attendance Signout(should automatically signout if the system is idle after some time ,not about session expiring),I dont want to openerp session time out .

Very complicated solution, you are putting the bar very high !!!

It's a "Google" translation from French "Mettre la barre très haut", which means the question is reaching a High Level of difficulties and need more skills (Nothing bad)