From 0177d64d717ba4f3a7b4f5f0305b14f811014f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Mon, 16 Mar 2026 19:49:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_catering/models/yuthon_catering.py | 36 +++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/yuthon_catering/models/yuthon_catering.py b/yuthon_catering/models/yuthon_catering.py index e72338dba..baff94f9b 100644 --- a/yuthon_catering/models/yuthon_catering.py +++ b/yuthon_catering/models/yuthon_catering.py @@ -198,7 +198,7 @@ class YuthonCatering(models.Model): # 补全后自动确认当天所有未确认记录 self.cron_auto_confirm_today() - # 定时任务:每天晙21点把当天未确认的餐饮记录自动改为已确认 + # 定时任务:每天晙21点把当天未确认的餐饮记录自动改为已确认并早餐午餐都吃(除外派) def cron_auto_confirm_today(self): today = fields.Date.today() # 检查当天是否有菜单记录,没有则跳过 @@ -210,7 +210,39 @@ class YuthonCatering(models.Model): ('state', '=', 'unconfirmed'), ]) if unconfirmed_records: - unconfirmed_records.write({'state': 'confirmed'}) + for record in unconfirmed_records: + if self.is_expatriates(today, record.employee_id): + breakfast = False + lunch = False + else: + breakfast = True + lunch = True + record.write({'state': 'confirmed', + 'breakfast': breakfast, 'lunch': lunch}) + + + def is_expatriates(self, current_data, employee): + expat_approval = self.env['expatriation.approval'].search([ + ('is_effect', '=', False), + ('work_end', '=', True), + ('expatriates_ids', 'in', [employee.id]) + ], limit=1) + # 查找有效的返回审批单 + back_approval = self.env['back.approval'].search([ + ('is_void', '=', False), + ('work_end', '=', True), + ('expatriates_id', '=', employee.id) + ], limit=1) + + # 3. 外派中:当前时间 >= 外派开始日期 → 属于外派 + if expat_approval and expat_approval.start_date: + if current_data >= expat_approval.start_date: + return True + + if back_approval and back_approval.end_date: + if current_data >= back_approval.end_date: + return False + # 定义定时任务方法,每天九点半发送消息提醒 def cron_send_message(self):