From 65c136c97b6c8c38f95eae3855afa56a66d846af Mon Sep 17 00:00:00 2001 From: ljmwkx <1340053001@qq.com> Date: Mon, 31 Mar 2025 22:05:26 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E5=81=87=E6=9C=9F?= =?UTF-8?q?=E6=89=93=E5=8D=A1=E8=AE=B0=E5=BD=95=E7=9A=84=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=20=E5=BE=85=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/hr_attendance_detail_wechat.py | 78 ++++++++++++++++--- 1 file changed, 69 insertions(+), 9 deletions(-) diff --git a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py index c43143125..8a2fb3e22 100644 --- a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py +++ b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py @@ -391,15 +391,17 @@ class HrAttendanceDetail(models.Model): current_day = current_date.split('-')[2] current_week = calendar.weekday(int(current_year), int(current_month), int(current_day)) work_time_result = self.get_employee_work_time(hr_employee_obj, current_week, current_date, tz) - # 说明今天休息 - if not work_time_result: - attendance_obj.sudo().write({ - "is_late_card": False, - "is_early_card": False, - "is_no_card": False, - "is_abnormal": False, - }) - return True + # # 说明今天休息 + # if not work_time_result: + # # 如果有人打开那么进行记录 + # + # attendance_obj.sudo().write({ + # "is_late_card": False, + # "is_early_card": False, + # "is_no_card": False, + # "is_abnormal": False, + # }) + # return True # 今天正常上班 # go_from, go_to, off_from, off_to, current_date = work_time_result # 获取考勤日历的上班下班时间 @@ -419,6 +421,64 @@ class HrAttendanceDetail(models.Model): check_out_start = datetime.strptime(str(current_date) + " " + "10:00", "%Y-%m-%d %H:%M") - timedelta(hours=8) check_out_end = datetime.strptime(str(current_date) + " " + "05:00", "%Y-%m-%d %H:%M") + relativedelta(days=1) - timedelta(hours=8) + # 说明今天休息 + if not work_time_result: + # 如果有人打卡那么进行记录 相当于白名单 + # 上班 + attendance_detail_obj_in = self.env['hr.attendance.detail'].sudo().search( + [("exception_type", "!=", "未打卡"), + ("userid", "=", user.oauth_uid), + ("checkin_time", ">=", check_in_start), + ("checkin_time", "<=", check_in_end)]) + if len(attendance_detail_obj_in) > 0: + # 多次打卡时间的集合 + checkin_time_list = [obj.checkin_time for obj in attendance_detail_obj_in] + if checkin_time_list: + # 最早 时间 + min_time = max(checkin_time_list) + attendance_obj.sudo().write({ + "sch_check_in_time": will_datetime_start, + "check_in": min_time, + "is_late_card": False, + "is_early_card": False, + "is_no_card": False, + "is_abnormal": False, + }) + # 下班 + attendance_detail_obj_out = self.env['hr.attendance.detail'].sudo().search( + [("exception_type", "!=", "未打卡"), + ("userid", "=", user.oauth_uid), + ("checkin_time", ">=", check_out_start), + ("checkin_time", "<=", check_out_end), + ]) + if len(attendance_detail_obj_out) > 0: + checkout_time_list = [obj.checkin_time for obj in attendance_detail_obj_out] + if checkout_time_list: + # 最早 时间 + max_time = max(checkout_time_list) + # 没有上班卡 + if not attendance_obj.check_in: + attendance_obj.sudo().write({ + "sch_check_in_time": will_datetime_start, + "check_in": max_time, + "is_late_card": False, + "is_no_card": False, + "is_abnormal": False, + "absenteeism_card": False, + }) + elif attendance_obj.check_in and attendance_obj.check_in < max_time: + attendance_obj.sudo().write({ + "sch_check_out_time": will_datetime_end, + "check_out": max_time, + "is_late_card": False, + "is_early_card": False, + "is_no_card": False, + "is_abnormal": False, + }) + # 关联 打卡详情 + attendance_detail_obj_in.hr_attendance_id = attendance_obj.id + return True + # 上班 attendance_detail_obj_in = self.env['hr.attendance.detail'].sudo().search( [("exception_type", "!=", "未打卡"), From 736d3499ffe4f7c445b783b41607f49808be965f Mon Sep 17 00:00:00 2001 From: ljmwkx <1340053001@qq.com> Date: Mon, 31 Mar 2025 22:07:48 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E5=81=87=E6=9C=9F?= =?UTF-8?q?=E6=89=93=E5=8D=A1=E8=AE=B0=E5=BD=95=E7=9A=84=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=20=E5=BE=85=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/hr_attendance_detail_wechat.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py index 8a2fb3e22..2b29b1a2f 100644 --- a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py +++ b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py @@ -431,6 +431,8 @@ class HrAttendanceDetail(models.Model): ("checkin_time", ">=", check_in_start), ("checkin_time", "<=", check_in_end)]) if len(attendance_detail_obj_in) > 0: + # 关联 打卡详情 + attendance_detail_obj_in.hr_attendance_id = attendance_obj.id # 多次打卡时间的集合 checkin_time_list = [obj.checkin_time for obj in attendance_detail_obj_in] if checkin_time_list: @@ -452,6 +454,7 @@ class HrAttendanceDetail(models.Model): ("checkin_time", "<=", check_out_end), ]) if len(attendance_detail_obj_out) > 0: + attendance_detail_obj_out.hr_attendance_id = attendance_obj.id checkout_time_list = [obj.checkin_time for obj in attendance_detail_obj_out] if checkout_time_list: # 最早 时间 @@ -475,8 +478,13 @@ class HrAttendanceDetail(models.Model): "is_no_card": False, "is_abnormal": False, }) - # 关联 打卡详情 - attendance_detail_obj_in.hr_attendance_id = attendance_obj.id + attendance_obj.sudo().write({ + "is_late_card": False, + "is_early_card": False, + "is_no_card": False, + "is_abnormal": False, + }) + return True # 上班 From 3b51efbf87db03fb21d88d6ce928b68dab541490 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Tue, 1 Apr 2025 09:22:23 +0800 Subject: [PATCH 3/3] =?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_salary/models/inherit_hr_payslip.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py index 4dc1765f8..8f766e3a9 100644 --- a/yuthon_salary/models/inherit_hr_payslip.py +++ b/yuthon_salary/models/inherit_hr_payslip.py @@ -193,7 +193,7 @@ class InheritHrPayslip(models.Model): "target": "new", } - @api.depends('line_ids','year_compute', 'year_jie', 'year_gong', 'jing_te') + @api.depends('line_ids','year_compute', 'year_jie', 'year_gong', 'jing_te', 'based_pay', 'study_on') def _compute_total_before_tax(self): common_records = self.env['yuthon.payroll.common'].search([('before_tax', '=', True)]) name_list = [record.name for record in common_records] @@ -202,7 +202,7 @@ class InheritHrPayslip(models.Model): for line in record.line_ids: if line.name in name_list: total += line.total - record.total_before_tax = total + record.base_salary + record.performance_bonuses + record.rank_salary + record.year_compute + record.year_jie + record.year_gong + record.jing_te + record.high_temperature_allowance + record.total_before_tax = total + record.base_salary + record.performance_bonuses + record.rank_salary + record.year_compute + record.year_jie + record.year_gong + record.jing_te + record.high_temperature_allowance + record.based_pay +record.study_on def put_button(self): for record in self: