From 3e6d1e4c14cc9cbdc50e75dbaf6af3f1cab80fd3 Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Thu, 9 Jan 2025 10:50:35 +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_hr_attendance/models/hr_attendance.py | 20 +++++++++++++++++++
.../security/planning_group.xml | 2 +-
.../views/hr_attendance_views.xml | 9 ++++++++-
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/yuthon_hr_attendance/models/hr_attendance.py b/yuthon_hr_attendance/models/hr_attendance.py
index cf2d32362..6c5674337 100644
--- a/yuthon_hr_attendance/models/hr_attendance.py
+++ b/yuthon_hr_attendance/models/hr_attendance.py
@@ -165,6 +165,26 @@ class HrAttendance(models.Model):
will_datetime_end = current_date.replace(year=year, month=month, day=day, hour=max_hour, minute=max_minute) - timedelta(hours=8)
record.write({'check_out': will_datetime_end, 'is_approval': True})
+ def button_batch_correct(self):
+ attendance_ids = self.env["hr.attendance"].browse(self._context.get('active_ids', self._context.get('active_id')))
+ for record in attendance_ids:
+ year = record.current_data.year
+ month = record.current_data.month
+ day = record.current_data.day
+ current_date = datetime.today()
+ min_hour_from = record.employee_id.resource_id.calendar_id.attendance_ids[0].hour_from
+ min_hour = int(min_hour_from)
+ min_minute = int(min_hour_from * 10 % min_hour_from)
+ will_datetime_start = current_date.replace(year=year, month=month, day=day, hour=min_hour,
+ minute=min_minute) - timedelta(hours=8)
+ record.write({'check_in': will_datetime_start, 'is_approval': True})
+ max_hour_to = record.employee_id.resource_id.calendar_id.attendance_ids[-1].hour_to
+ max_hour = int(max_hour_to)
+ max_minute = int(max_hour_to * 10 % max_hour_to)
+ will_datetime_end = current_date.replace(year=year, month=month, day=day, hour=max_hour,
+ minute=max_minute) - timedelta(hours=8)
+ record.write({'check_out': will_datetime_end, 'is_approval': True})
+
@api.depends('current_data')
def _compute_week(self):
for record in self:
diff --git a/yuthon_hr_attendance/security/planning_group.xml b/yuthon_hr_attendance/security/planning_group.xml
index ea139f154..3513e086a 100644
--- a/yuthon_hr_attendance/security/planning_group.xml
+++ b/yuthon_hr_attendance/security/planning_group.xml
@@ -96,7 +96,7 @@
- 计划考勤管理员
+ 计划考勤管理员
diff --git a/yuthon_hr_attendance/views/hr_attendance_views.xml b/yuthon_hr_attendance/views/hr_attendance_views.xml
index ef169e745..79f625d3d 100644
--- a/yuthon_hr_attendance/views/hr_attendance_views.xml
+++ b/yuthon_hr_attendance/views/hr_attendance_views.xml
@@ -48,7 +48,7 @@
+ invisible="not is_abnormal" groups="yuthon_hr_attendance.group_he_attendance_planning_manager"/>
@@ -101,4 +101,11 @@
{"search_default_employee": 1}
[('employee_id.yuthon_company', '=', 'thwg')]
+
+ 批量修正
+
+
+ code
+ action = model.button_batch_correct()
+