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
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
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.
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 3 19
|
6376 | ||
|
4
thg 10 24
|
10263 | ||
|
0
thg 10 23
|
810 | ||
|
0
thg 12 21
|
2131 | ||
|
0
thg 7 21
|
2815 |
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