fix records_to_notify
This commit is contained in:
parent
22c2cbb85a
commit
ec5a0cf55f
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<!-- <data noupdate="1">-->
|
||||
<record id="hr_attendance_transaction_create" model="ir.cron">
|
||||
<field name="name">Attendance Transaction</field>
|
||||
<field name="model_id" ref="model_hr_attendance_transaction"/>
|
||||
|
|
@ -53,5 +53,5 @@
|
|||
]]>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
<!-- </data>-->
|
||||
</odoo>
|
||||
|
|
|
|||
|
|
@ -1118,19 +1118,19 @@ class HrAttendanceTransactions(models.Model):
|
|||
@api.model
|
||||
def send_lateness_notifications(self):
|
||||
yesterday = datetime.now().date() - timedelta(days=1)
|
||||
|
||||
records_to_notify = self.search([
|
||||
('date', '=', yesterday), '|', '|',
|
||||
('lateness', '>', 0),
|
||||
('early_exit', '>', 0),
|
||||
('is_absent', '=', True)
|
||||
])
|
||||
records_to_notify = self.search([('date', '=', yesterday)])
|
||||
|
||||
template_id = self.env.ref('attendances.attendance_notification_email_template').id
|
||||
for record in records_to_notify:
|
||||
if template_id:
|
||||
template = self.env['mail.template'].browse(template_id)
|
||||
template.send_mail(record.id, force_send=True)
|
||||
if (
|
||||
record.lateness > 0 and
|
||||
record.early_exit > 0 and
|
||||
record.is_absent and
|
||||
(record.sign_out == 0 or record.sign_in == 0)
|
||||
):
|
||||
if template_id:
|
||||
template = self.env['mail.template'].browse(template_id)
|
||||
template.send_mail(record.id, force_send=True)
|
||||
|
||||
# @api.multi
|
||||
# def unlink(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue