校验:
result = True
if record.employee_id.employee_type_rep:
if record.employee_id.employee_type_rep.code=='O_CN':
if record.product_uom_id.name=='小时' or record.product_uom_id.name=='Hour(s)':
total_time = record.leave_total
else:
total_time = record.leave_total*8
annual_id = env['hr.holiday.type'].search([('code','=','L001')])
holiday_recs = env['hr.holiday.leave'].search([('employee_id','=',record.employee_id.id),('holiday_type_id','=',annual_id.id),('state','in',['waiting','done']),('active','=',True)])
for holiday_rec in holiday_recs:
if holiday_rec.product_uom_id.name=='小时' or holiday_rec.product_uom_id.name=='Hour(s)':
total_time += holiday_rec.leave_total
else:
total_time = holiday_rec.leave_total*8
if total_time>24:
raise ValidationError('试用期员工年休假不能超过3天,加上本次申请已经累计申请{}小时'.format(str(total_time)))
分流:
result = False
cost_centers = ['DT-2191', 'DT-2195', 'DT-2198']
if record.employee_id.cost_center:
if record.employee_id.cost_center.code in cost_centers:
result = True
result = False
cost_centers = ['DT-2109', 'DT-2192', 'DT-2193', 'DT-2196','DT-2199']
if record.employee_id.cost_center:
if record.employee_id.cost_center.code in cost_centers:
result = True