添加功能

This commit is contained in:
李鹏宇
2026-05-11 16:27:12 +08:00
parent 0a1d3c85f6
commit 2442401210
@@ -527,6 +527,7 @@ class OvertimeApprovals(models.Model):
def _compute_overtime_type(self):
for record in self:
current_date = datetime.today()
record.type_overtime = 'work'
if record.start_time and record.end_time:
if record.start_time > record.end_time:
raise UserError("开始时间不能晚于结束时间")
@@ -554,10 +555,16 @@ class OvertimeApprovals(models.Model):
date_str = start_date.strftime('%m月%d日')
date_str = self.remove_leading_zero(date_str)
is_weekend = start_date.weekday() in [5, 6]
if date_str in statutory_set:
# 调班补班日
if date_str in shift_days_set:
record.type_overtime = 'work'
# 法定节假日
elif date_str in statutory_set:
record.type_overtime = 'holiday'
# 周末 或 调休日
elif date_str in holidays_set or is_weekend:
record.type_overtime = 'weekend'
# 普通工作日
else:
record.type_overtime = 'work'