Merge pull request !2242 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2025-04-01 01:23:32 +00:00
committed by Gitee
2 changed files with 79 additions and 11 deletions
@@ -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,72 @@ 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:
# 关联 打卡详情
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:
# 最早 时间
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:
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:
# 最早 时间
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_obj.sudo().write({
"is_late_card": False,
"is_early_card": False,
"is_no_card": False,
"is_abnormal": False,
})
return True
# 上班
attendance_detail_obj_in = self.env['hr.attendance.detail'].sudo().search(
[("exception_type", "!=", "未打卡"),
+2 -2
View File
@@ -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: