pengyuthon wechat

This commit is contained in:
李鹏宇
2024-12-18 09:08:26 +08:00
parent fd423dd462
commit ef99f6c1cb
7 changed files with 425 additions and 427 deletions
@@ -69,61 +69,6 @@ class HrAttendance(models.Model):
format_datetime(self.env, attendance.check_out, dt_format="HH:mm"),
)
# @api.depends('check_in', 'check_out')
# def _compute_attendance_flags(self):
# for record in self:
# record.is_no_card = False
# record.is_late_card = False
# record.is_early_card = False
# if not record.employee_id.resource_id.calendar_id.attendance_ids:
# department_names = ['保安部', '班组A', '班组B', '班组C', '工程部', '运行班', '高压班', '综合班']
# department_ids = self.env['hr.department'].search([('name', 'in', department_names)]).ids
# employee_ids = self.env['hr.employee'].search([('department_id', 'in', department_ids)])
# for employee_id in employee_ids:
# planning_ids = self.env['planning.slot'].search([('resource_id', '=', employee_id.resource_id.id)])
# for planning_id in planning_ids:
# start_date = planning_id.start_datetime.date()
# attendance_id = self.env['hr.attendance'].search(
# [('employee_id', '=', employee_id.id), ('current_data', '=', start_date)])
# if attendance_id:
# if attendance_id.check_in:
# check_in = attendance_id.check_in + timedelta(hours=8)
# attendance_id.is_late_card = check_in > planning_id.start_datetime
# else:
# attendance_id.is_no_card = True
# if attendance_id.check_out:
# check_in = attendance_id.check_in + timedelta(hours=8)
# attendance_id.is_early_card = planning_id.end_datetime > check_in
# else:
# attendance_id.is_no_card = True
# else:
# 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)
# if record.check_in:
# check_in = record.check_in + timedelta(hours=8)
# will_datetime_start = check_in.replace(hour=min_hour, minute=min_minute)
# record.is_late_card = check_in > will_datetime_start
# else:
# record.is_no_card = 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)
# if record.check_out:
# check_out = record.check_out + timedelta(hours=8)
# will_datetime_end = check_out.replace(hour=max_hour, minute=max_minute)
# record.is_early_card = will_datetime_end > check_out
# else:
# record.is_no_card = True
# if record.employee_id in record.employee_id.resource_id.calendar_id.resource_user_ids:
# if record.check_in or record.check_out:
# record.write({
# 'is_abnormal': False,
# 'is_late_card': False,
# 'is_early_card': False,
# 'is_no_card': False
# })
def add_comment(self):
self.ensure_one()
menu_id = self.env['ir.ui.menu'].search([('name', '=', '我的异常')])
@@ -153,14 +98,6 @@ class HrAttendance(models.Model):
title="打卡异常提醒", description="本月迟到: {}\n本月缺卡: {}\n本月早退: {}\n".format(is_late_card, is_no_card, is_early_card),
url=str, btntxt="详细信息")
# @api.depends('is_no_card', 'is_early_card', 'is_late_card')
# def _compute_is_abnormal(self):
# for record in self:
# record.is_abnormal = False
# if record.week not in ["six", "seven"]:
# record.is_abnormal = record.is_no_card or record.is_early_card or record.is_late_card
# record.abnormal = int(record.is_no_card or record.is_early_card or record.is_late_card)
def button_leave(self):
form_id = self.env.ref('yuthon_holiday.view_hr_leave_batch_form').id
return {
@@ -3,6 +3,7 @@ from datetime import datetime, time, timedelta, date
from odoo.exceptions import UserError
# todo 默认当前月份,安排下个月是月份字段+1 注意月份 Selection用1-12 代码优化
class YuthonDutyPlan(models.Model):
_name = 'yuthon.duty.plan'
_description = '值班计划'
@@ -12,13 +13,19 @@ class YuthonDutyPlan(models.Model):
end_index_time = fields.Date(string='失效时间')
is_enable = fields.Boolean(string="启用", default=True)
plan_line_ids = fields.One2many('duty.plan.line', 'duty_plan_id', string='关联计划明细')
white_line_ids = fields.One2many('white.plan.line', 'duty_plan_id', string='关联计划明细')
notice = fields.Text(string='计划说明')
select_time = fields.Selection([('January', '一月'), ('February', '二月'), ('March', '三月'), ('April', '四月'),
('May', '五月'), ('June', '六月'), ('July', '七月'), ('August', '八月'),
('September', '九月'), ('October', '十月'), ('November', '十一月'),
('December', '十二月')], string='选择月份')
# default = lambda self: self._default_month()
# @api.model
# def _default_month(self):
# current_month = datetime.now().strftime('%B')
# return current_month
def auto_duty_plan(self,next_date=False):
def auto_duty_plan(self, next_date=False):
month_names = {
'January': 1, 'February': 2, 'March': 3, 'April': 4,
'May': 5, 'June': 6, 'July': 7, 'August': 8,
@@ -92,6 +99,38 @@ class YuthonDutyPlan(models.Model):
week = i.start_datetime.weekday()
if week == 5 or week == 6:
i.sudo().unlink()
other_data = {}
for other in self.white_line_ids:
if other.employee_id:
other_resource_id = other.employee_id.resource_id
regular_holiday = other.regular_holidays
weekday_mapping = {'one': 7, 'two': 1, 'three': 2, 'four': 3, 'five': 4, 'six': 5, 'seven': 6}
weekday_number = weekday_mapping.get(regular_holiday)
other_data[other_resource_id.id] = weekday_number
for employee in self.white_line_ids:
current_date = first_day_of_month
while current_date <= last_day_of_month:
current_datetime = datetime.combine(current_date, time(0, 0, 0))
start_hour = int(role_template_a.start_time)
end_hour = int(role_template_a.end_time)
start_time = current_datetime.replace(hour=start_hour, minute=30) - timedelta(hours=8)
end_time = current_datetime.replace(hour=end_hour, minute=30) - timedelta(hours=8)
resource_id = employee.employee_id.resource_id
if not other_data[resource_id.id] == datetime(current_date.year, current_date.month,current_date.day).weekday():
self.env['planning.slot'].create({
'template_id': self.env['planning.slot.template'].search([('role_id', '=', role_a.id), ('planning_name', '=', '白班')]).id,
'resource_id': resource_id.id,
'start_datetime': datetime(current_date.year, current_date.month, current_date.day, start_time) + timedelta(hours=16) - timedelta(days=1),
'end_datetime': datetime(current_date.year, current_date.month, current_date.day, end_time) + timedelta(hours=16) - timedelta(days=1),
'role_id': role_a.id,
'allocated_hours': 8,
})
current_date += timedelta(days=1)
if current_date > last_day_of_month:
break
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
@@ -105,6 +144,7 @@ class YuthonDutyPlan(models.Model):
def duty_next_plan(self):
self.auto_duty_plan(next_date=True)
class DutyPlanLine(models.Model):
_name = 'duty.plan.line'
_description = '值班计划明细行'
@@ -113,3 +153,15 @@ class DutyPlanLine(models.Model):
duty_plan_id = fields.Many2one('yuthon.duty.plan', string='关联计划名称')
employee_ids = fields.Many2many('hr.employee', string='值班人员')
duty_class_id = fields.Many2one('yuthon.duty.class.setting', string="班组名称")
class WhitePlanLine(models.Model):
_name = 'white.plan.line'
_description = '值班常白计划明细行'
sequence = fields.Char(string='序号', store=True)
duty_plan_id = fields.Many2one('yuthon.duty.plan', string='关联计划名称')
employee_id = fields.Many2one('hr.employee', string='值班人员')
regular_holidays = fields.Selection([('one', '星期一'), ('two', '星期二'), ('three', '星期三'),
('four', '星期四'), ('five', '星期五'), ('six', '星期六'),
('seven', '星期日')], string='固定休息日')
@@ -3,6 +3,7 @@ from datetime import datetime, time, timedelta
from odoo.exceptions import UserError
from datetime import date, timedelta
class YuthonRunPlanning(models.Model):
_name = 'yuthon.run.planning'
_description = '工程部排班计划'
@@ -25,6 +25,7 @@ access_yuthon_customer_approval,yuthon.customer.approval,model_yuthon_customer_a
access_yuthon_duty_plan,yuthon.duty.plan,model_yuthon_duty_plan,base.group_user,1,1,1,1
access_duty_plan_line,duty.plan.line,model_duty_plan_line,base.group_user,1,1,1,1
access_white_plan_line,white.plan.line,model_white_plan_line,base.group_user,1,1,1,1
access_yuthon_duty_class_setting,yuthon.duty.class.setting,model_yuthon_duty_class_setting,base.group_user,1,1,1,1
access_yuthon_adjustments_approval,yuthon.adjustments.approval,model_yuthon_adjustments_approval,base.group_user,1,1,1,1
access_yuthon_abnormal_approval,yuthon.abnormal.approval,model_yuthon_abnormal_approval,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
25 access_yuthon_adjustments_approval access_yuthon_duty_class_setting yuthon.adjustments.approval yuthon.duty.class.setting model_yuthon_adjustments_approval model_yuthon_duty_class_setting base.group_user 1 1 1 1
26 access_yuthon_abnormal_approval access_yuthon_adjustments_approval yuthon.abnormal.approval yuthon.adjustments.approval model_yuthon_abnormal_approval model_yuthon_adjustments_approval base.group_user 1 1 1 1
27 access_yuthon_abnormal_setting access_yuthon_abnormal_approval yuthon.abnormal.setting yuthon.abnormal.approval model_yuthon_abnormal_setting model_yuthon_abnormal_approval base.group_user 1 1 1 1
28 access_yuthon_abnormal_setting yuthon.abnormal.setting model_yuthon_abnormal_setting base.group_user 1 1 1 1
29 access_yuthon_shift_approval yuthon.shift.approval model_yuthon_shift_approval base.group_user 1 1 1 1
30 access_yuthon_special_approval yuthon.special.approval model_yuthon_special_approval base.group_user 1 1 1 1
31 access_card_remind_form card.remind.form model_card_remind_form base.group_user 1 1 1 1
@@ -160,28 +160,31 @@
<field name="res_model">hr.attendance</field>
<field name="view_mode">tree,form</field>
<field name="context">{"search_default_employee": 1}</field>
<field name="domain">[('employee_id.yuthon_company','=','thtz'), ('week', 'not in', ['seven', 'six'])]]</field>
<field name="domain">[('employee_id.yuthon_company','=','thtz'), ('week', 'not in', ['seven', 'six'])]</field>
</record>
<record id="action_attendance_yuthon_company_form2" model="ir.actions.act_window">
<field name="name">天河粮储</field>
<field name="res_model">hr.attendance</field>
<field name="view_mode">tree,form</field>
<field name="context">{"search_default_employee": 1}</field>
<field name="domain">[('employee_id.yuthon_company', '=', 'thlc'), ('week', 'not in', ['seven', 'six'])]]</field>
<field name="domain">[('employee_id.yuthon_company', '=', 'thlc'),
('week', 'not in', ['seven', 'six']),
('employee_id.department_id.name','not in',['仓储组', '综合组','保管组', '机安组', '1库', '2库', '3库', '联安粮库'])]</field>
</record>
<record id="action_attendance_yuthon_company_form3" model="ir.actions.act_window">
<field name="name">天河物管</field>
<field name="res_model">hr.attendance</field>
<field name="view_mode">tree,form</field>
<field name="context">{"search_default_employee": 1}</field>
<field name="domain">[('employee_id.yuthon_company', '=', 'thwg'), ('week', 'not in', ['seven', 'six'])]]</field>
<field name="domain">[('employee_id.yuthon_company', '=', 'thwg'), ('week', 'not in', ['seven', 'six']),
('employee_id.department_id.name','not in',['运行班', '高压班','综合班','班组A', '班组B','班组C'])]</field>
</record>
<record id="hr_attendance_action2" model="ir.actions.act_window">
<field name="name">考勤记录</field>
<field name="res_model">hr.attendance</field>
<field name="view_mode">tree</field>
<field name="context">{"search_default_employee": 1}</field>
<field name="domain">[('employee_id.department_id.name','in',['保安部', '班组A', '班组B','班组C'])]</field>
<field name="domain">[('employee_id.department_id.name','in',['班组A', '班组B','班组C'])]</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_hr_attendance.view_attendance_going_tree3')})]"/>
</record>
@@ -190,7 +193,7 @@
<field name="res_model">hr.attendance</field>
<field name="view_mode">tree</field>
<field name="context">{"search_default_employee": 1}</field>
<field name="domain">[('employee_id.department_id.name','in',['工程部', '运行班', '高压班','综合班'])]]</field>
<field name="domain">[('employee_id.department_id.name','in',['运行班', '高压班','综合班'])]</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_hr_attendance.view_attendance_going_tree4')})]"/>
</record>
@@ -199,7 +202,7 @@
<field name="res_model">hr.attendance</field>
<field name="view_mode">tree,form</field>
<field name="context">{"search_default_employee": 1}</field>
<field name="domain">[('employee_id.department_id.name','in',['仓储组', '综合组','保管组', '机安组', '1库', '2库', '3库', '联安粮库'])]]</field>
<field name="domain">[('employee_id.department_id.name','in',['仓储组', '综合组','保管组', '机安组', '1库', '2库', '3库', '联安粮库'])]</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_hr_attendance.view_attendance_going_tree5')})]"/>
</record>
@@ -39,21 +39,31 @@
<field name="is_enable"/>
</group>
</group>
<notebook>
<page string="值班人员">
<field name="plan_line_ids">
<tree editable="bottom">
<field name="duty_plan_id" column_invisible="1"/>
<field name="sequence" widget="handle"/>
<field name="employee_ids" required="1"
domain="[('department_id.name', 'in', ['仓储组', '综合组','保管组',
'机安组','1库', '2库', '3库','联安粮库'])]"
widget="many2many_tags"/>
<field name="duty_class_id" required="1"/>
</tree>
</field>
</page>
</notebook>
<group string="值班人员"/>
<div>
<field name="plan_line_ids">
<tree editable="bottom">
<field name="duty_plan_id" column_invisible="1"/>
<field name="sequence" widget="handle"/>
<field name="employee_ids" required="1"
domain="[('department_id.name', 'in', ['仓储组', '综合组','保管组', '机安组','1库', '2库', '3库','联安粮库'])]"
widget="many2many_tags"/>
<field name="duty_class_id" required="1"/>
</tree>
</field>
</div>
<group string="常白人员"/>
<div>
<field name="white_line_ids">
<tree editable="bottom">
<field name="duty_plan_id" column_invisible="1"/>
<field name="sequence" widget="handle"/>
<field name="employee_id" required="1"
domain="[('department_id.name', 'in', ['仓储组', '综合组','保管组', '机安组','1库', '2库', '3库','联安粮库'])]"/>
<field name="regular_holidays"/>
</tree>
</field>
</div>
</sheet>
</form>
</field>
+336 -342
View File
@@ -266,349 +266,343 @@ class HrAttendanceDetail(models.Model):
exception_type = data.get("exception_type", "")
will_datetime_start = checkin_time.replace(hour=min_hour, minute=min_minute)
will_datetime_end = checkin_time.replace(hour=max_hour, minute=max_minute)
if hr_employee_obj.default_planning_role_id:
if exception_type != "未打卡":
if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
})
elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
})
elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
})
elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif attendance_obj.is_early_card or attendance_obj.is_late_card:
attendance_obj.sudo().write({"is_abnormal": True})
else:
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
# if not hr_employee_obj.default_planning_role_id:
if exception_type != "未打卡":
if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
})
elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
})
elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
})
elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif attendance_obj.is_early_card or attendance_obj.is_late_card:
attendance_obj.sudo().write({"is_abnormal": True})
else:
current_datetime_start = datetime.datetime.combine(current_data, datetime.time.min)
current_datetime_end = datetime.datetime.combine(current_data, datetime.time.max)
planning_slot_id = self.env['planning.slot'].search([('resource_id', '=', hr_employee_obj.resource_id.id),
('start_datetime', '>=', current_datetime_start),
('start_datetime', '<=', current_datetime_end)])
if planning_slot_id:
if planning_slot_id.department_id.name == '保安部':
attendance_obj = self.env['hr.attendance'].sudo().create({
'employee_id': hr_employee_obj.id,
"userid": userid,
"current_data": current_data,
"shift_id": planning_slot_id.id,
"attendance_type": "wx_work"
})
if exception_type != "未打卡":
if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif attendance_obj.is_early_card or attendance_obj.is_late_card:
attendance_obj.sudo().write({"is_abnormal": True})
elif planning_slot_id.department_id.name == '工程部':
attendance_obj = self.env['hr.attendance'].sudo().create({
'employee_id': hr_employee_obj.id,
"userid": userid,
"current_data": current_data,
"shift_id": planning_slot_id.id,
"attendance_type": "wx_work"
})
if planning_slot_id.template_id.planning_name == '中值':
if exception_type != "未打卡":
if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif datetime.time(11, 30)<= checkin_time <= datetime.time(13, 30):
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"noon_duty":False
})
elif attendance_obj.is_early_card or attendance_obj.is_late_card or attendance_obj.noon_duty:
attendance_obj.sudo().write({"is_abnormal": True})
else:
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
elif planning_slot_id.template_id.planning_name == '夜值':
if exception_type != "未打卡":
if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif (datetime.time(9, 30) <= checkin_time <= datetime.time(23, 59, 59) or
datetime.time(0, 0) <= checkin_time <= datetime.time(6, 0)):
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"night_duty": False
})
elif attendance_obj.is_early_card or attendance_obj.is_late_card or attendance_obj.night_duty:
attendance_obj.sudo().write({"is_abnormal": True})
else:
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
else:
if exception_type != "未打卡":
if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif attendance_obj.is_early_card or attendance_obj.is_late_card or attendance_obj.noon_duty:
attendance_obj.sudo().write({"is_abnormal": True})
else:
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
elif planning_slot_id.department_id.name == '联安粮库':
attendance_obj = self.env['hr.attendance'].sudo().create({
'employee_id': hr_employee_obj.id,
"userid": userid,
"current_data": current_data,
"shift_id": planning_slot_id.id,
"attendance_type": "wx_work"
})
if planning_slot_id.template_id.planning_name == '夜值':
if exception_type != "未打卡":
if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif (datetime.time(9, 30) <= checkin_time <= datetime.time(23, 59, 59) or
datetime.time(0, 0) <= checkin_time <= datetime.time(6, 0)):
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"night_duty": False
})
elif attendance_obj.is_early_card or attendance_obj.is_late_card or attendance_obj.noon_duty:
attendance_obj.sudo().write({"is_abnormal": True})
else:
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
else:
if exception_type != "未打卡":
if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif attendance_obj.is_early_card or attendance_obj.is_late_card:
attendance_obj.sudo().write({"is_abnormal": True})
else:
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
# 进行关联
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
# else:
# current_datetime_start = datetime.datetime.combine(datetime.datetime.strptime(current_data, '%Y-%m-%d'), datetime.time.min)
# current_datetime_end = datetime.datetime.combine(datetime.datetime.strptime(current_data, '%Y-%m-%d'), datetime.time.max)
# planning_slot_id = self.env['planning.slot'].search([('resource_id', '=', hr_employee_obj.resource_id.id),
# ('start_datetime', '>=', current_datetime_start),
# ('start_datetime', '<=', current_datetime_end)])
# if planning_slot_id:
# if planning_slot_id.department_id.name == '保安部':
# attendance_obj = self.env['hr.attendance'].sudo().create({
# 'employee_id': hr_employee_obj.id,
# "userid": userid,
# "current_data": current_data,
# "shift_id": planning_slot_id.id,
# "attendance_type": "wx_work"
# })
# if exception_type != "未打卡":
# if checkin_time and checkin_type == "上班打卡" and not attendance_obj.check_in:
# attendance_obj.sudo().write({
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and checkin_type == "下班打卡" and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and checkin_time < attendance_obj.check_in:
# attendance_obj.sudo().write({
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and checkin_time > attendance_obj.check_out:
# attendance_obj.sudo().write({
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif checkin_time and not attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif attendance_obj.is_early_card or attendance_obj.is_late_card:
# attendance_obj.sudo().write({"is_abnormal": True})
# elif planning_slot_id.department_id.name == '工程部':
# attendance_obj = self.env['hr.attendance'].sudo().create({
# 'employee_id': hr_employee_obj.id,
# "userid": userid,
# "current_data": current_data,
# "shift_id": planning_slot_id.id,
# "attendance_type": "wx_work"
# })
# if planning_slot_id.template_id.planning_name == '中值':
# if exception_type != "未打卡":
# if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif datetime.time(11, 30)<= checkin_time <= datetime.time(13, 30):
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "noon_duty":False
# })
# elif attendance_obj.is_early_card or attendance_obj.is_late_card or attendance_obj.noon_duty:
# attendance_obj.sudo().write({"is_abnormal": True})
# else:
# attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
# elif planning_slot_id.template_id.planning_name == '夜值':
# if exception_type != "未打卡":
# if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif (datetime.time(9, 30) <= checkin_time <= datetime.time(23, 59, 59) or
# datetime.time(0, 0) <= checkin_time <= datetime.time(6, 0)):
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "night_duty": False
# })
# elif attendance_obj.is_early_card or attendance_obj.is_late_card or attendance_obj.night_duty:
# attendance_obj.sudo().write({"is_abnormal": True})
# else:
# attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
# else:
# if exception_type != "未打卡":
# if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif attendance_obj.is_early_card or attendance_obj.is_late_card or attendance_obj.noon_duty:
# attendance_obj.sudo().write({"is_abnormal": True})
# else:
# attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
# elif planning_slot_id.department_id.name == '联安粮库':
# attendance_obj = self.env['hr.attendance'].sudo().create({
# 'employee_id': hr_employee_obj.id,
# "userid": userid,
# "current_data": current_data,
# "shift_id": planning_slot_id.id,
# "attendance_type": "wx_work"
# })
# if planning_slot_id.template_id.planning_name == '夜值':
# if exception_type != "未打卡":
# if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif (datetime.time(9, 30) <= checkin_time <= datetime.time(23, 59, 59) or
# datetime.time(0, 0) <= checkin_time <= datetime.time(6, 0)):
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "night_duty": False
# })
# elif attendance_obj.is_early_card or attendance_obj.is_late_card or attendance_obj.noon_duty:
# attendance_obj.sudo().write({"is_abnormal": True})
# else:
# attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
# else:
# if exception_type != "未打卡":
# if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_in_time": sch_checkin_time,
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "sch_check_out_time": sch_checkin_time,
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif attendance_obj.is_early_card or attendance_obj.is_late_card:
# attendance_obj.sudo().write({"is_abnormal": True})
# else:
# attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
# # 进行关联
attendance_detail_obj.hr_attendance_id = attendance_obj.id
return True
def get_hr_attendance_time(self):