代码:
result = True
today = datetime.datetime.now().strftime('%Y-%m-%d')
if record.employee_id.overtime_conf_id.name in ['正常加班规则','调休或换薪加班规则'] and today>=record.start_date:
raise ValidationError('正常加班规则&调休和换薪加班规则:只允许提交明天及之后加班日期的加班申请')
if record.employee_id.overtime_conf_id.name=='发行部加班规则':
代码:
result = True
today = datetime.datetime.now().strftime('%Y-%m-%d')
if record.employee_id.overtime_conf_id.name in ['正常加班规则','调休或换薪加班规则'] and today>=record.start_date:
raise ValidationError('正常加班规则&调休和换薪加班规则:只允许提交明天及之后加班日期的加班申请')
if record.employee_id.overtime_conf_id.name=='发行部加班规则':
week_day = datetime.datetime.strptime(record.start_date,'%Y-%m-%d').weekday()
line = env ['work.calendar.line'] .search( [('work_calendar_id','=',record.employee_id.work_calendar_id.id),('day','=',record.start_date)] )
if (week_day>=5 and not line) or (line and line.day_type!='work'):
raise ValidationError('adfdf')
if today>=record.start_date:
raise ValidationError('发行部加班规则:加班日期为工作日的话,提交时间不受限制,加班日期为周末OR节假日的话,只允许提交明天及之后加班日期的加班申请')