!4569 添加功能

Merge pull request !4569 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-08-15 06:41:33 +00:00
committed by Gitee
2 changed files with 33 additions and 4 deletions
@@ -88,6 +88,7 @@ class HrAttendanceDetail(models.Model):
if record.employee_id and record.checkin_time and record.checkin_type != '未打卡':
self._update_actual_attendance(record)
self._sync_to_hr_attendance(record)
_logger.info(f"{record.employee_id.name}--------")
return record
def _update_actual_attendance(self, record):
@@ -121,9 +122,37 @@ class HrAttendanceDetail(models.Model):
attendance.check_in = record.checkin_time
attendance.check_out = record.checkin_time
else:
now_time = fields.Datetime.to_datetime(checkin_date) + timedelta(hours=8, days=1)
start_time = now_time - timedelta(days=2)
self.env["hr.attendance.detail"].get_hr_attendance_time(record.employee_id, now_time, start_time)
local_start = datetime.combine(checkin_date, datetime.min.time())
local_end = local_start + timedelta(days=1)
utc_start = local_start - timedelta(hours=8)
utc_end = local_end - timedelta(hours=8)
domain = [
("exception_type", "!=", "未打卡"),
('employee_id', '=', record.employee_id.id),
('checkin_time', '>=', fields.Datetime.to_string(utc_start)),
('checkin_time', '<', fields.Datetime.to_string(utc_end))
]
check_in = None
check_out = None
attendance_records = self.env['hr.attendance.detail'].search(domain)
if attendance_records:
checkin_times = sorted(attendance_records.mapped('checkin_time'))
check_in = checkin_times[0]
if len(checkin_times) == 1:
check_out = 0
else:
check_out = checkin_times[-1]
if check_in is not None:
attendance.create({
'employee_id': record.employee_id.id,
'check_in': check_in,
'check_out': check_out,
'current_data': checkin_date,
})
# now_time = fields.Datetime.to_datetime(checkin_date) + timedelta(hours=8, days=1)
# start_time = now_time - timedelta(days=2)
# self.env["hr.attendance.detail"].get_hr_attendance_time(record.employee_id, now_time, start_time)
@@ -258,6 +258,6 @@ class PropertyReconciliationLine(models.Model):
rent = fields.Float(string='未收')
amount = fields.Float(string='金额', store=True)
collection_type = fields.Selection([('deposit', '押金'), ('rent', '租金'), ('water_fee', '水费'),
('electricity_fee', '电费'), ('penalty', '违约'), ('management_fee', '管理费'), ('repair_fee', '维修费'),
('electricity_fee', '电费'), ('penalty', '违约金'), ('management_fee', '管理费'), ('repair_fee', '维修费'),
('other', '其他')], string='收款类型')
remake = fields.Char(string='备注')