From 6ffbc461525d152d0808abb91887d9c598ea0a16 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, 26 Jan 2026 14:52:45 +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 --- .../models/overtime_approval.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/yuthon_hr_attendance/models/overtime_approval.py b/yuthon_hr_attendance/models/overtime_approval.py index 179b35065..4c2611136 100644 --- a/yuthon_hr_attendance/models/overtime_approval.py +++ b/yuthon_hr_attendance/models/overtime_approval.py @@ -58,6 +58,23 @@ class OvertimeApprovals(models.Model): name_title = fields.Char(default=_get_default_name_title) self_users_ids = fields.Many2many('res.users', string="当前经办人", default=lambda self: [(6, 0, [self.env.user.id])]) + @api.constrains('start_time') + def _check_start_time(self): + for rec in self: + workflow_records = self.env['soong.workflow.record'].search([ + ('workflow_id.name', '=', '加班'), + ('create_uid', '=', self.env.user.id), + ]) + if not workflow_records: + continue + for wf_rec in workflow_records: + target_model = self.env[wf_rec.res_model] + target_record = target_model.browse(wf_rec.res_id) + if not target_record.exists() or not target_record.start_time: + continue + if target_record.start_time.date() == rec.start_time.date(): + raise UserError('当天已有加班审批,请重新选择开始时间') + def open_record(self): if self.start_time and self.end_time and self.employee_ids: start_date = fields.Date.to_date(self.start_time)