콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
5 답글
9999 화면

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.

아바타
취소
작성자

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

베스트 답변

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.

관련 게시물 답글 화면 활동
2
6월 25
6887
4
10월 24
10959
0
10월 23
1209
0
12월 21
2510
0
7월 21
3255