diff --git a/yuthon_catering/models/yuthon_catering.py b/yuthon_catering/models/yuthon_catering.py index baff94f9b..91abe6b5b 100644 --- a/yuthon_catering/models/yuthon_catering.py +++ b/yuthon_catering/models/yuthon_catering.py @@ -211,7 +211,7 @@ class YuthonCatering(models.Model): ]) if unconfirmed_records: for record in unconfirmed_records: - if self.is_expatriates(today, record.employee_id): + if self.is_expatriates(today, record.employee_id) or self.is_leave(today, record.employee_id): breakfast = False lunch = False else: @@ -243,6 +243,16 @@ class YuthonCatering(models.Model): if current_data >= back_approval.end_date: return False + def is_leave(self, current_data, employee): + att_id = self.env['hr.attendance'].search([ + ('employee_id', '=', employee.id), + ('current_data', '=', current_data) + ], limit=1) + if att_id and att_id.workflow_id and att_id.workflow_id.name == '请假': + record_id = self.env[att_id.workflow_id.res_model].search([('id', '=', att_id.workflow_id.res_id)]) + if record_id: + if record_id.days >= 1: + return True # 定义定时任务方法,每天九点半发送消息提醒 def cron_send_message(self):