@@ -198,7 +198,7 @@ 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(check_in_time, check_out_time, sch_check_in_time, sch_check_out_time, 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)
|
||||
if attendance:
|
||||
attendance.write({
|
||||
'check_in': check_in_time,
|
||||
@@ -266,7 +266,7 @@ class HrAttendanceDetail(models.Model):
|
||||
minutes = int((hour_float - hours) * 60)
|
||||
return datetime.combine(base_date, datetime.min.time()) + timedelta(hours=hours, minutes=minutes)
|
||||
|
||||
def state_judgment(self, check_in, check_out, start_datetime, end_datetime, current_data):
|
||||
def state_judgment(self, employee, check_in, check_out, start_datetime, end_datetime, current_data):
|
||||
"""
|
||||
判断打卡状态
|
||||
:param check_in: 签到时间
|
||||
@@ -284,30 +284,36 @@ class HrAttendanceDetail(models.Model):
|
||||
absenteeism_card = False
|
||||
|
||||
# 判断是否工作日
|
||||
if self._process_shift_days(current_data):
|
||||
if not check_in or not check_out:
|
||||
is_no_card = True
|
||||
# 迟到判断
|
||||
if check_in and start_datetime and check_in > start_datetime:
|
||||
is_late_card = True
|
||||
# 计算迟到时长(分钟)
|
||||
late_delta = (check_in - start_datetime).total_seconds() / 60
|
||||
# 迟到超过60分钟标记为旷工
|
||||
if late_delta > 60:
|
||||
absenteeism_card = True
|
||||
# 早退判断
|
||||
if check_out and end_datetime and check_out < end_datetime:
|
||||
is_early_card = True
|
||||
# 计算早退时长(分钟)
|
||||
early_delta = (end_datetime - check_out).total_seconds() / 60
|
||||
# 早退超过60分钟标记为旷工
|
||||
if early_delta > 60:
|
||||
absenteeism_card = True
|
||||
if employee.company_id.name == "集团本部":
|
||||
if not self._process_shift_days(current_data):
|
||||
return is_no_card, is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card
|
||||
|
||||
# 异常和警告判断
|
||||
if is_no_card or is_early_card or is_late_card:
|
||||
is_abnormal = True
|
||||
is_warning = True
|
||||
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 :
|
||||
is_late_card = False
|
||||
employee.late_allowed -= 1
|
||||
else:
|
||||
is_late_card = True
|
||||
late_delta = (check_in - start_datetime).total_seconds() / 60
|
||||
# 迟到超过60分钟标记为旷工
|
||||
if late_delta > 60:
|
||||
absenteeism_card = True
|
||||
# 早退判断
|
||||
if check_out and end_datetime and check_out < end_datetime:
|
||||
is_early_card = True
|
||||
# 计算早退时长(分钟)
|
||||
early_delta = (end_datetime - check_out).total_seconds() / 60
|
||||
# 早退超过60分钟标记为旷工
|
||||
if early_delta > 60:
|
||||
absenteeism_card = True
|
||||
|
||||
# 异常和警告判断
|
||||
if is_no_card or 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
|
||||
|
||||
|
||||
@@ -15,5 +15,19 @@
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
</record>
|
||||
<record forcecreate="True" id="late_arrivals_are_allowed" model="ir.cron">
|
||||
<field name="name">定时任务:重置物管允许迟到次数</field>
|
||||
<field name="model_id" ref="model_hr_employee"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model.compute_late_allowed()</field>
|
||||
<field eval="True" name="active"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">months</field>
|
||||
<field name="nextcall"
|
||||
eval="(DateTime.now() + relativedelta(day=1)).strftime('%Y-%m-%d 00:00:00')"/>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -128,7 +128,7 @@ class YuthonHrEmployee(models.Model):
|
||||
previous_balance = fields.Float(string="上年结余")
|
||||
quota_issued = fields.Float(string="本年发放额度")
|
||||
deadline = fields.Date(string="截止日期")
|
||||
|
||||
late_allowed = fields.Float(string="允许迟到次数")
|
||||
|
||||
# 其他信息
|
||||
employment_registration = fields.Text(string="就业登记办理情况")
|
||||
@@ -216,6 +216,11 @@ class YuthonHrEmployee(models.Model):
|
||||
security_amount = fields.Float(string="安全委员会金额", compute='_compute_subsidy_amount', store=True)
|
||||
quality_inspector_amount = fields.Float(string="质检员金额", compute='_compute_subsidy_amount', store=True)
|
||||
|
||||
def compute_late_allowed(self):
|
||||
employee = self.env["hr.employee"].search([('company_id.name', '=', '天河物管')])
|
||||
for employee_id in employee:
|
||||
employee_id.late_allowed = 3
|
||||
|
||||
@api.onchange('user_role_id')
|
||||
def _onchange_user_role_id(self):
|
||||
if self.user_role_id and self.id:
|
||||
|
||||
@@ -142,6 +142,7 @@
|
||||
<field name="compute_char"/>
|
||||
<field name="social_insurance_date"/>
|
||||
<field name="social_insurance_time"/>
|
||||
<field name="late_allowed"/>
|
||||
<field name="is_annual_salary"/>
|
||||
<field name="is_accum_salary"/>
|
||||
<field name="is_membership"/>
|
||||
@@ -197,6 +198,7 @@
|
||||
<field name="holiday_overtime_hours" readonly="0"/>
|
||||
<field name="all_overtime_hours" readonly="1"/>
|
||||
<field name="overtime_this_month" readonly="1"/>
|
||||
<field name="late_allowed" readonly="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="normal_overtime_hours1" readonly="0"/>
|
||||
|
||||
Reference in New Issue
Block a user