diff --git a/yuthon_wechat/models/hr_attendance_detail.py b/yuthon_wechat/models/hr_attendance_detail.py index a0b1be194..e23e6afd2 100644 --- a/yuthon_wechat/models/hr_attendance_detail.py +++ b/yuthon_wechat/models/hr_attendance_detail.py @@ -751,6 +751,18 @@ class HrAttendanceDetail(models.Model): check_out_start = template_id.check_out_start # check_out_end = fields.Datetime(string="下班结束") check_out_end = template_id.check_out_end + + # 这里需要将 浮点型时间转为 时间型 + check_in_start = self.str_to_time(current_date, check_in_start) + check_in_end = self.str_to_time(current_date, check_in_end) + check_out_start = self.str_to_time(current_date, check_out_start) + check_out_end = self.str_to_time(current_date, check_out_end) + # 如果结束时间小于开始时间说明 是第二天的时间 + if check_in_end < check_in_start: + check_in_end = check_in_end + relativedelta(days=1) + if check_out_end < check_out_start: + check_out_end = check_out_end + relativedelta(days=1) + # 判断打卡情况排除未打卡情况 # 上班 attendance_detail_obj = self.env['hr.attendance.detail'].sudo().search( @@ -819,4 +831,17 @@ class HrAttendanceDetail(models.Model): current_date = start_time + relativedelta(days=1) time_ranges.append(current_date.strftime("%Y-%m-%d")) start_time = current_date - return time_ranges \ No newline at end of file + return time_ranges + + @staticmethod + def str_to_time(current_data, data): + """ + %d:%d 的 str类型的时间转换成时间 + :param current_data: 当前日期 + :param data: str类型时间 + :return: 转换后的时间 + """ + from_time = "%d:%d" % (int(data), round((data - int(data)) * 60)) + from_times = str(current_data) + " " + from_time + from_ti = datetime.strptime(from_times, "%Y-%m-%d %H:%M") + return from_ti \ No newline at end of file diff --git a/yuthon_wechat/models/planning_slot_template.py b/yuthon_wechat/models/planning_slot_template.py index b94e820a8..106d5f455 100644 --- a/yuthon_wechat/models/planning_slot_template.py +++ b/yuthon_wechat/models/planning_slot_template.py @@ -5,9 +5,9 @@ from odoo import api, fields, models, _ class PlanningTemplate(models.Model): _inherit = 'planning.slot.template' - check_in_start = fields.Datetime(string="上班开始") - check_in_end = fields.Datetime(string="上班结束") + check_in_start = fields.Char(string="上班开始") + check_in_end = fields.Char(string="上班结束") - check_out_start = fields.Datetime(string="下班开始") - check_out_end = fields.Datetime(string="下班结束") + check_out_start = fields.Char(string="下班开始") + check_out_end = fields.Char(string="下班结束")