I want to create a cron job that will customize attendance module such that the employees who forgot to check out will be checked out automatically at a particular time and at the same time an email would be sent stating "you forgot to checkout, we have checked you out".
I have already created a cron job with auto checkout functionality, that is working perfectly fine. Now I want to send an email as well to those employees.
Here is my code.
```python
class hr_attendance(models.Model):
_inherit = 'hr.attendance'
def check_for_incomplete_attendances(self):
not_checkout = self.env['hr.attendance'].search([('check_out', '=', False)])
for rec in not_checkout:
date_time = (datetime.now() + timedelta(days=0)).strftime('%Y-%m-%d 18:29:59')
rec.check_out = date_time
```
```xml
<odoo>
<data noupdate = "1">
<record id="ir_cron_module_auto_checkout" model="ir.cron">
<field name="name">Auto Checkout</field>
<field eval="True" name="auto_checkout"/>
<field name="interval_number">1</field>
<field name="nextcall" eval="(DateTime.now() + timedelta(days=0)).strftime('%Y-%m-%d 18:29:59')"/>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="True" name="doall" />
<field name="model_id" ref="hr_attendance.model_hr_attendance"/>
<field name="state">code</field>
<field name="code">
model.check_for_incomplete_attendances()
</field>
</record>
</data>
</odoo>