diff --git a/yuthon_hr_attendance/models/card_approval.py b/yuthon_hr_attendance/models/card_approval.py
index 54705e0f5..621512f71 100644
--- a/yuthon_hr_attendance/models/card_approval.py
+++ b/yuthon_hr_attendance/models/card_approval.py
@@ -18,6 +18,8 @@ class CardApprovals(models.Model):
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
employee_id = fields.Many2one(related='users_id.employee_id', string="员工")
department_id = fields.Many2one(related='users_id.employee_id.department_id', string="部门")
+ shift_id = fields.Many2one('planning.slot', string="班次", store=True)
+ shift_name = fields.Char(string="班次", related="shift_id.template_id.planning_name")
is_issues = fields.Boolean(string='是否上会')
related_issues_id = fields.Many2one('issue.library', string="关联议题")
reason_application = fields.Html(string="申请事由")
@@ -29,7 +31,7 @@ class CardApprovals(models.Model):
@api.depends('attendance_id')
def _compute_replacement_time(self):
for rep in self:
- rep.replacement_time = 'all'
+ rep.replacement_time = None
if rep.attendance_id.is_early_card and not rep.attendance_id.is_late_card:
rep.replacement_time = 'quitting'
if rep.attendance_id.is_late_card and not rep.attendance_id.is_early_card:
diff --git a/yuthon_hr_attendance/models/hr_attendance.py b/yuthon_hr_attendance/models/hr_attendance.py
index 393acb559..46dfb1c0d 100644
--- a/yuthon_hr_attendance/models/hr_attendance.py
+++ b/yuthon_hr_attendance/models/hr_attendance.py
@@ -31,7 +31,7 @@ class HrAttendance(models.Model):
('four', '四'), ('five', '五'), ('six', '六'),
('seven', '日')], string='星期', compute='_compute_week', store=True)
abnormal = fields.Integer(string="异常计算")
- shift_id = fields.Many2one('planning.slot', string="班次", store=True) # ? 用哪个??
+ shift_id = fields.Many2one('planning.slot', string="班次", store=True)
shift_name = fields.Char(string="班次", related="shift_id.template_id.planning_name")
noon_duty = fields.Datetime(string="中值")
night_duty = fields.Datetime(string="晚值")
@@ -132,6 +132,7 @@ class HrAttendance(models.Model):
"context": {
'default_attendance_id': self.id,
'default_users_id': self.employee_id.user_id.id,
+ 'default_shift_id':self.shift_id.id
}
}
@@ -157,12 +158,12 @@ class HrAttendance(models.Model):
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})
+ record.write({'check_in': will_datetime_start, 'is_approval': True, 'is_abnormal':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})
+ record.write({'check_out': will_datetime_end, 'is_approval': True, 'is_abnormal':False })
def button_batch_correct(self):
attendance_ids = self.env["hr.attendance"].browse(self._context.get('active_ids', self._context.get('active_id')))
@@ -176,13 +177,13 @@ class HrAttendance(models.Model):
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})
+ record.write({'check_in': will_datetime_start, 'is_approval': True, 'is_abnormal':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})
+ record.write({'check_out': will_datetime_end, 'is_approval': True, 'is_abnormal':False})
@api.depends('current_data')
def _compute_week(self):
diff --git a/yuthon_hr_attendance/views/card_approval.xml b/yuthon_hr_attendance/views/card_approval.xml
index 68e2a50d8..cc36f4d6d 100644
--- a/yuthon_hr_attendance/views/card_approval.xml
+++ b/yuthon_hr_attendance/views/card_approval.xml
@@ -23,7 +23,7 @@
-
+
@@ -32,7 +32,11 @@
-
+
+
+
+
+