!2238 添加功能

Merge pull request !2238 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-03-31 12:44:33 +00:00
committed by Gitee
3 changed files with 75 additions and 33 deletions
@@ -87,8 +87,6 @@ class HrLeaveAllocation(models.Model):
now_type = 'hours'
else:
now_type = 'days'
self.write({'is_approval': True, 'is_abnormal': False, 'is_no_card': False,
'is_early_card': False, 'is_late_card': False})
return {
"type": "ir.actions.act_window",
"name": "修正申请",
@@ -103,6 +101,7 @@ class HrLeaveAllocation(models.Model):
'default_original_hours': self.number_of_days_display,
}
}
def all_refuse(self):
leave_ids = self.env["hr.leave.allocation"].browse(
self._context.get('active_ids', self._context.get('active_id')))
+73 -30
View File
@@ -156,40 +156,83 @@ class HrAttendance(models.Model):
def button_correct_approval(self):
for record in self:
year = record.current_data.year
month = record.current_data.month
day = record.current_data.day
current_date = datetime.today()
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)
will_datetime_start = current_date.replace(year=year, month=month, day=day, hour=min_hour, minute=min_minute) - timedelta(hours=8)
record.write({'check_in': will_datetime_start, 'is_approval': True, 'is_abnormal':False, 'is_no_card':False, 'is_early_card':False, 'is_late_card':False})
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)
will_datetime_end = current_date.replace(year=year, month=month, day=day, hour=max_hour, minute=max_minute) - timedelta(hours=8)
record.write({'check_out': will_datetime_end, 'is_approval': True, 'is_abnormal':False, 'is_no_card':False, 'is_early_card':False, 'is_late_card':False })
if not record.shift_id:
year = record.current_data.year
month = record.current_data.month
day = record.current_data.day
current_date = datetime.today()
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)
will_datetime_start = current_date.replace(year=year, month=month, day=day, hour=min_hour, minute=min_minute) - timedelta(hours=8)
record.write({'check_in': will_datetime_start, 'is_approval': True, 'is_abnormal':False, 'is_no_card':False, 'is_early_card':False, 'is_late_card':False})
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)
will_datetime_end = current_date.replace(year=year, month=month, day=day, hour=max_hour, minute=max_minute) - timedelta(hours=8)
record.write({'check_out': will_datetime_end, 'is_approval': True, 'is_abnormal':False, 'is_no_card':False, 'is_early_card':False, 'is_late_card':False })
else:
check_in_start = record.shift_id.template_id.check_in_start
check_out_end = record.shift_id.template_id.check_out_end
date = record.current_data
start_hour = int(check_in_start)
start_minute = int((check_in_start - start_hour) * 60)
end_hour = int(check_out_end)
end_minute = int((check_out_end - end_hour) * 60)
# 拼接成 datetime 对象
start_datetime = datetime.combine(date, datetime.min.time()).replace(
hour=start_hour, minute=start_minute, second=0, microsecond=0
)
end_datetime = datetime.combine(date, datetime.min.time()).replace(
hour=end_hour, minute=end_minute, second=0, microsecond=0
)
if record.shift_id.template_id.day2 == '次日':
end_datetime = end_datetime + timedelta(days=1)
record.write(
{'check_out': end_datetime, 'check_in':start_datetime, 'is_approval': True, 'is_abnormal': False, 'is_no_card': False,
'is_early_card': False, 'is_late_card': False})
def button_batch_correct(self):
attendance_ids = self.env["hr.attendance"].browse(self._context.get('active_ids', self._context.get('active_id')))
for record in attendance_ids:
year = record.current_data.year
month = record.current_data.month
day = record.current_data.day
current_date = datetime.today()
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)
will_datetime_start = current_date.replace(year=year, month=month, day=day, hour=min_hour,
minute=min_minute) - timedelta(hours=8)
record.write({'check_in': will_datetime_start, 'is_approval': True, 'is_abnormal':False, 'is_no_card':False, 'is_early_card':False, 'is_late_card':False})
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)
will_datetime_end = current_date.replace(year=year, month=month, day=day, hour=max_hour,
minute=max_minute) - timedelta(hours=8)
record.write({'check_out': will_datetime_end, 'is_approval': True, 'is_abnormal':False, 'is_no_card':False, 'is_early_card':False, 'is_late_card':False})
if not record.shift_id:
year = record.current_data.year
month = record.current_data.month
day = record.current_data.day
current_date = datetime.today()
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)
will_datetime_start = current_date.replace(year=year, month=month, day=day, hour=min_hour,
minute=min_minute) - timedelta(hours=8)
record.write({'check_in': will_datetime_start, 'is_approval': True, 'is_abnormal':False, 'is_no_card':False, 'is_early_card':False, 'is_late_card':False})
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)
will_datetime_end = current_date.replace(year=year, month=month, day=day, hour=max_hour,
minute=max_minute) - timedelta(hours=8)
record.write({'check_out': will_datetime_end, 'is_approval': True, 'is_abnormal':False, 'is_no_card':False, 'is_early_card':False, 'is_late_card':False})
else:
check_in_start = record.shift_id.template_id.check_in_start
check_out_end = record.shift_id.template_id.check_out_end
date = record.current_data
start_hour = int(check_in_start)
start_minute = int((check_in_start - start_hour) * 60)
end_hour = int(check_out_end)
end_minute = int((check_out_end - end_hour) * 60)
# 拼接成 datetime 对象
start_datetime = datetime.combine(date, datetime.min.time()).replace(
hour=start_hour, minute=start_minute, second=0, microsecond=0
)
end_datetime = datetime.combine(date, datetime.min.time()).replace(
hour=end_hour, minute=end_minute, second=0, microsecond=0
)
if record.shift_id.template_id.day2 == '次日':
end_datetime = end_datetime + timedelta(days=1)
record.write(
{'check_out': end_datetime, 'check_in': start_datetime, 'is_approval': True, 'is_abnormal': False,
'is_no_card': False,
'is_early_card': False, 'is_late_card': False})
@api.depends('current_data')
def _compute_week(self):
@@ -28,7 +28,7 @@
<button name="button_leave" type="object" string="请假" class="oe_highlight" invisible="not (is_abnormal or is_early_card or is_late_card or absenteeism_card or is_no_card)"/>
<button name="button_card_approval" type="object" string="补卡" class="oe_highlight" invisible="not (is_abnormal or is_early_card or is_late_card or absenteeism_card or is_no_card)"/>
<button name="button_duty_approval" type="object" string="外出" class="oe_highlight" invisible="not (is_abnormal or is_early_card or is_late_card or absenteeism_card or is_no_card)"/>
<button name="button_correct_approval" type="object" string="修正" class="oe_highlight" groups="yuthon_hr_attendance.group_he_attendance_planning_manager"/>
<button name="button_correct_approval" type="object" string="修正" class="oe_highlight" groups="yuthon_hr_attendance.group_he_attendance_planning_manager" invisible="is_approval"/>
</tree>
</field>
</record>