From f3c1a7be5c8491c8d543ca206eaf9ad1e0854504 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: Thu, 12 Feb 2026 16:48:12 +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/planning_template_inherit.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/yuthon_hr_attendance/models/planning_template_inherit.py b/yuthon_hr_attendance/models/planning_template_inherit.py index 751d7a9b3..15628328c 100644 --- a/yuthon_hr_attendance/models/planning_template_inherit.py +++ b/yuthon_hr_attendance/models/planning_template_inherit.py @@ -111,7 +111,6 @@ class PlanningSlotTemplate(models.Model): ) shift_template.display_name = name - class Planning(models.Model): _inherit = 'planning.slot' @@ -127,11 +126,18 @@ class Planning(models.Model): planning_name = slot.template_id.planning_name if slot.template_id and slot.template_id.planning_name else "" new_start_datetime = slot.start_datetime + timedelta(hours=8) start_time_str = new_start_datetime.strftime("%Y-%m-%d") - # new_end_datetime = slot.end_datetime + timedelta(hours=8) - # end_time_str = new_end_datetime.strftime("%H:%M:%S") - # slot.display_name = f"{planning_name + '/' + start_time_str}" slot.display_name = f"{planning_name}" + @api.constrains('template_id') + def _check_template_id(self): + for slot in self: + if slot.template_id: + new_start_datetime = slot.start_datetime + timedelta(hours=8) + att_id = self.env['hr.attendance'].search([('employee_id', '=', slot.resource_id.employee_id.id), ('current_data', '=', new_start_datetime.date())]) + if att_id: + att_id.compute_attend() + + @api.depends('template_id.color') def _compute_color(self): for slot in self: