简体   繁体   English

Odoo 13' 解决员工在odoo考勤时忘记结账的解决方案

[英]Odoo 13' solution to solve about the employee forget to checkout in odoo attendance

I would like to ask about the auto checkout in attendance odoo, because employees often forget to check out.想问一下考勤odoo的自动结账,因为员工经常忘记结账。 Thus, I would like to mark their checkout automatically.因此,我想自动标记他们的结帐。

How is the code and where I can insert this code?代码如何以及我可以在哪里插入此代码?

Thank you!谢谢!

I have code for auto checkout in Attendance module of Odoo server:我在 Odoo 服务器的出勤模块中有自动结帐代码:

model.cron_set_attedance_checkout() class hr_attendace(models.Model): model.cron_set_attedance_checkout() 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

I received an error:我收到一个错误:

SyntaxError: invalid syntax at line 9 SyntaxError:第 9 行的语法无效

records = self.search([('check_out', '=', False), ('check_in', ',=': False)]):记录 = self.search([('check_out', '=', False), ('check_in', ',=': False)]):

Please help!请帮忙!

Thank you!谢谢!

Remove the ":" at the end of the line.删除行尾的“:”。

records = self.search([('check_out', '=', False), ('check_in', '!=', False)])

Place this in check in button method.将此放置在签入按钮方法中。

self.expires_in = int(round(time.time() * 1000))

Activate a scheduler whose interval is 1 mint.激活间隔为 1 分钟的调度程序。 To check the following lines.检查以下几行。

expires_in = datetime.fromtimestamp(int(self.expires_in) / 1e3)
expires_in = expires_in + timedelta(seconds=32400) //9 hours seconds
nowDateTime = datetime.now()
if nowDateTime > expires_in:
   checkout_button_method()

Let me explain little bit.. The above most line execute a store a check in time.让我稍微解释一下.. 上面最上面的行执行存储签入时间。 After scheduler is running it will adding 9 hours after its check in. If time is greater than 9 hours it automatically calls the checkout method and perform checkout button duty.调度程序运行后,它会在签入后增加 9 小时。如果时间大于 9 小时,它会自动调用 checkout 方法并执行结帐按钮任务。

@Adam, I have followed your instructions. @Adam,我已按照您的指示进行操作。

在此处输入图像描述 But I received the error:但我收到了错误:

在此处输入图像描述

In last update You Must Delete comment sarting with // then save it work fine.在上次更新中,您必须删除以 // 开头的评论,然后保存它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM