if an employee forget to checkout in odoo attendance python code for auto checkout in attendance odoo and write the checkout time as check in time.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
Hi,
Here if you are looking to automatically create a checkout for those employees who forget to check out, you can create a scheduled action and calls a python function and do it.
But make sure that it will not affect/cause any issue.
You can create a scheduled action by referring to this link: Automated action in Odoo
Then in the Python function that the action calls,
not_checkout = self.env['hr.attendance'].search([('checkout', '=', False)])
for rec in not_checkout:
date_time = 'prefered date time here'
rec.check_out = date_time
If you check the above Python code you can see that attendance which is not checked out yet is fetched and a DateTime is given as checkout time.
In the search, method make sure that the current date's record is only fetched.
Thanks
Hi,
Somehow if I use this code the automatic check out is still not working. Can someone add a screenshot of their scheduled action?
hello
create an schedule action and into that set the "Execute Every 1 Days", "Next Execution Date = datetime(datetime must be like 2018-01-01 00:00:00), code = model.cron_set_attedance_checkout(), model= Attendance"
Python code:
class hr_attendace(models.Model)
_inherit = 'hr.attendance'
@api.model
def cron_set_attedance_checkout(self):
records = self.search([('check_out', '=', False), ('check_in', '!=', False)]):
for record in records:
record.check_out = record.check_in
Hi Mitul
Can you send a screenshot please? Also can you do the reverse to check in as well. I prefer to have each day of the month in the attendance record so if you download the time data for the month, each day appears, days worked and off days. Just a query.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Mar 19
|
6371 | ||
|
4
Oct 24
|
10253 | ||
|
0
Oct 23
|
810 | ||
|
0
Dec 21
|
2129 | ||
|
0
Jul 21
|
2811 |
yes i tried to create scheduled action but it is not working.i want auto check out at12am everyday..
What is not working? scheduled action? please refer the blog in the given answer, it might be for v10 anyway with slight change it will work for v11 or above, if you check the existing Odoo code itself, you will get a lot of sample of the scheduled actions