@@ -1,16 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record forcecreate="True" id="attendance_time_data" model="ir.cron">
|
||||
<field name="name">定时任务:检查考勤是否异常</field>
|
||||
<record forcecreate="True" id="attendance_missing_card_judgment" model="ir.cron">
|
||||
<field name="name">定时任务:考勤缺卡判断</field>
|
||||
<field name="model_id" ref="model_hr_attendance"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model.card_remind()</field>
|
||||
<field name="code">model.missing_card_judgment()</field>
|
||||
<field eval="True" name="active"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">days</field>
|
||||
<field name="nextcall" eval="(DateTime.now()).strftime('%Y-%m-%d 13:00:00')"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="nextcall" eval="(DateTime.now()).strftime('%Y-%m-%d 23:00:00')"/>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
</record>
|
||||
|
||||
@@ -57,8 +57,6 @@ class HrAttendance(models.Model):
|
||||
is_month = fields.Boolean(string="是否为本月数据", compute='_compute_month_status', store=True)
|
||||
is_last_month = fields.Boolean(string="是否为上月数据", compute='_compute_month_status', store=True)
|
||||
|
||||
|
||||
|
||||
@api.depends('is_no_card', 'is_early_card', 'is_late_card', 'is_abnormal', 'absenteeism_card')
|
||||
def _compute_is_warning(self):
|
||||
for record in self:
|
||||
@@ -195,14 +193,18 @@ class HrAttendance(models.Model):
|
||||
if record.absenteeism_card:
|
||||
absenteeism_card += 1
|
||||
if has_abnormal:
|
||||
url = (f'https://oa.thtzjt.com/web?login={employee.user_id.login}&oauth_uid={employee.wecom_userid}&cids=2&action={menu_id.action.id}&menu_id={menu_id.id}&model={self._name}'
|
||||
f'&view_type=list#action={menu_id.action.id}&model={self._name}&view_type=list&menu_id={menu_id.id}')
|
||||
url = "#小程序://天投云/XttsPpKg3MEpY7h"
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='att', user_id=employee.wecom_userid, title="打卡异常提醒",
|
||||
description="本月迟到: {}\n本月缺卡: {}\n本月早退: {}\n本月异常:{}\n 本月旷工: {}\n"
|
||||
.format(is_late_card, is_no_card, is_early_card, is_abnormal, absenteeism_card),
|
||||
url=url, btntxt="详细信息")
|
||||
logging.info(f"打卡异常提醒发送成功,员工:{employee.name},本月迟到: {is_late_card},本月缺卡: {is_no_card},本月早退: {is_early_card},本月异常:{is_abnormal},本月旷工: {absenteeism_card}")
|
||||
|
||||
def missing_card_judgment(self):
|
||||
today = fields.Date.today()
|
||||
attend_records = self.env['hr.attendance'].search(['current_data', '=', today])
|
||||
for record in attend_records:
|
||||
record.is_no_card = not record.check_in or not record.check_out
|
||||
|
||||
@api.depends('employee_id', 'check_in', 'check_out')
|
||||
def _compute_display_name(self):
|
||||
|
||||
@@ -245,12 +245,11 @@ class HrAttendanceDetail(models.Model):
|
||||
)
|
||||
# 获取正常上下班时间
|
||||
sch_check_in_time, sch_check_out_time = self.normal_clock_in_time(template, current_data)
|
||||
is_no_card, is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card = self.state_judgment(employee, check_in_time, check_out_time, sch_check_in_time, sch_check_out_time, current_data)
|
||||
is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card = self.state_judgment(employee, check_in_time, check_out_time, sch_check_in_time, sch_check_out_time, current_data)
|
||||
if attendance:
|
||||
attendance.write({
|
||||
'check_in': check_in_time,
|
||||
'check_out': check_out_time,
|
||||
'is_no_card': is_no_card,
|
||||
'is_early_card': is_early_card,
|
||||
'is_late_card': is_late_card,
|
||||
'is_abnormal': is_abnormal,
|
||||
@@ -265,7 +264,6 @@ class HrAttendanceDetail(models.Model):
|
||||
'check_out': check_out_time,
|
||||
'sch_check_in_time': sch_check_in_time,
|
||||
'sch_check_out_time': sch_check_out_time,
|
||||
'is_no_card': is_no_card,
|
||||
'is_early_card': is_early_card,
|
||||
'is_late_card': is_late_card,
|
||||
'is_abnormal': is_abnormal,
|
||||
@@ -321,9 +319,8 @@ class HrAttendanceDetail(models.Model):
|
||||
:param start_datetime: 标准上班打卡时间
|
||||
:param end_datetime: 标准下班打卡时间
|
||||
:param current_data: 打卡日期
|
||||
:return: is_no_card, is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card
|
||||
:return: is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card
|
||||
"""
|
||||
is_no_card = False
|
||||
is_early_card = False
|
||||
is_late_card = False
|
||||
is_abnormal = False
|
||||
@@ -342,10 +339,8 @@ class HrAttendanceDetail(models.Model):
|
||||
if employee.id not in employee_list:
|
||||
# 判断是否工作日
|
||||
if not self._process_shift_days(current_data):
|
||||
return is_no_card, is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card
|
||||
return is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card
|
||||
|
||||
if not check_in or not check_out:
|
||||
is_no_card = True
|
||||
# 迟到判断
|
||||
if check_in and start_datetime and check_in > start_datetime:
|
||||
if employee.late_allowed > 0 :
|
||||
@@ -367,11 +362,11 @@ class HrAttendanceDetail(models.Model):
|
||||
absenteeism_card = True
|
||||
|
||||
# 异常和警告判断
|
||||
if is_no_card or is_early_card or is_late_card:
|
||||
if is_early_card or is_late_card:
|
||||
is_abnormal = True
|
||||
is_warning = True
|
||||
|
||||
return is_no_card, is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card
|
||||
return is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card
|
||||
|
||||
def _process_shift_days(self, current_data):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user