diff --git a/yuthon_hr_attendance/data/attendance_month_date.xml b/yuthon_hr_attendance/data/attendance_month_date.xml
index 05cad9be3..c4c7824ec 100644
--- a/yuthon_hr_attendance/data/attendance_month_date.xml
+++ b/yuthon_hr_attendance/data/attendance_month_date.xml
@@ -53,19 +53,5 @@
-1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/yuthon_hr_attendance/models/hr_attendance.py b/yuthon_hr_attendance/models/hr_attendance.py
index 5e04158ed..2cfa9473f 100644
--- a/yuthon_hr_attendance/models/hr_attendance.py
+++ b/yuthon_hr_attendance/models/hr_attendance.py
@@ -63,25 +63,25 @@ class HrAttendance(models.Model):
is_last_month = fields.Boolean(string="是否为上月数据", compute='_compute_month_status', store=True)
correct_result = fields.Text(string="修正原因")
- # @api.constrains("check_in")
- # def _check_in_out(self):
- # reminder_id = self.env['message.reminder.tasks'].search([('name', '=', self.employee_id.name), ('state', '=', 'todo'),
- # ('type', '=', 'work'),
- # ('current_data', '=', self.current_data)], limit=1)
- # if reminder_id:
- # reminder_id.state = 'done'
+ @api.constrains("check_in")
+ def _check_in_out(self):
+ reminder_id = self.env['message.reminder.tasks'].search([('name', '=', self.employee_id.name), ('state', '=', 'todo'),
+ ('type', '=', 'work'),
+ ('current_data', '=', self.current_data)], limit=1)
+ if reminder_id:
+ reminder_id.state = 'done'
- # @api.constrains("check_out")
- # def _check_out_in(self):
- # if self.shift_name in ['夜班', '旧晚(旧区府晚班)']:
- # current_data = self.current_data + timedelta(days=1)
- # else:
- # current_data = self.current_data
- # reminder_id = self.env['message.reminder.tasks'].search([('name', '=', self.employee_id.name), ('state', '=', 'todo'),
- # ('type', '=', 'offWork'),
- # ('current_data', '=', current_data)])
- # if reminder_id:
- # reminder_id.state = 'done'
+ @api.constrains("check_out")
+ def _check_out_in(self):
+ if self.shift_name in ['夜班', '旧晚(旧区府晚班)']:
+ current_data = self.current_data + timedelta(days=1)
+ else:
+ current_data = self.current_data
+ reminder_id = self.env['message.reminder.tasks'].search([('name', '=', self.employee_id.name), ('state', '=', 'todo'),
+ ('type', '=', 'offWork'),
+ ('current_data', '=', current_data)], limit=1)
+ if reminder_id:
+ reminder_id.state = 'done'
def one_time(self):
for att in self.env["hr.attendance"].browse(self._context.get('active_ids', self._context.get('active_id'))):
@@ -100,18 +100,28 @@ class HrAttendance(models.Model):
定时任务create_attendance_data_holiday
:return:
"""
- att_ids = self.sudo().env['hr.attendance']
- # 补充假期橙色逻辑,班次逻辑
- for emp in self.sudo().env['hr.employee'].search([('user_state', '!=', ['withdraw', 'leave'])]):
- test1 = att_ids.search([('current_data', '=', fields.Date.today()), ('employee_id', '=', emp.id)])
- resource_user_ids = emp.resource_calendar_id.resource_user_ids.ids
- is_resource_user = True if emp.id in resource_user_ids else False
- if not is_resource_user and not test1:
- new_att = att_ids.create({
- 'employee_id': emp.id,
- 'current_data': fields.Date.today(),
+ today = fields.Date.today() + timedelta(hours=8)
+ today_str = fields.Date.to_string(today)
+ existing_employees = self.env['hr.employee'].search([
+ ('name', 'not in', ['Administrator'])
+ ])
+ existing_records = self.search([
+ ('employee_id', 'in', existing_employees.ids),
+ ('current_data', '=', today_str)
+ ])
+ existing_employee_ids = set()
+ for record in existing_records:
+ existing_employee_ids.add(record.employee_id.id)
+ for employee in existing_employees:
+ if employee.id not in existing_employee_ids:
+ self.create({
+ 'employee_id': employee.id,
+ 'current_data': today_str,
+ 'check_in': False,
+ 'check_out': False,
+ 'is_no_card': False,
+ 'is_abnormal': False
})
- new_att.compute_attend()
def state_fix(self):
for att in self.env["hr.attendance"].browse(self._context.get('active_ids', self._context.get('active_id'))):