result = True
if record.holiday_type_id.code == 'L019' and record.employee_id.departure_time:
raise ValidationError('根据公司政策,已提离职不能申请带薪病假。')
elif record.holiday_type_id.code == 'L007' and not record.employee_id.departure_time:
if record.start_date >= record.employee_id.hiredate + relativedelta.relativedelta(months=3):
paid_leave_type = env['hr.holiday.type'].search([('code', '=', 'L019')], limit=1)
inquirys = env['hr.holiday.inquiry'].search([('employee_id', '=', record.employee_id.id), ('company_id', '=', record.company_id.id), ('holiday_type_id', '=', paid_leave_type.id), ('is_current_period', '=', True)])
month = datetime.datetime.now().month
balance = sum(inquirys.mapped('balances'))
dif = 0
for i in range(int(record.start_date[5:7]),month):
dif += 0.5
res = 0
for i in range(int(record.end_date[5:7]),month):
res += 0.5
if (int(record.start_date[5:7]) >= month) and (balance > dif) or (int(record.start_date[5:7]) <= int(record.end_date[5:7]) < month) and (balance > res) or (int(record.start_date[5:7]) < month <= int(record.end_date[5:7])) and balance > res:
raise ValidationError('根据休假规则您尚有带薪病假可用余额,请优先申请。')
elif record.holiday_type_id.code == 'L017' and ((record.start_date and record.employee_id.birthday and record.start_date[5:7] != record.employee_id.birthday[5:7]) or not record.employee_id.birthday):
raise ValidationError('根据公司政策,你的休假日期不满足生日假申请条件。')