result = True
if record.x_cqwrz == 'A02':
result = False
user_group_code = ['R008','R009','R133','R229','R081','R173']
eroad_ids = env['eroad.role'].search([('code','in',user_group_code)])
user_ids = []
for eroad in eroad_ids:
if eroad.user_ids:
for user in eroad.user_ids:
user_ids.append(user.id)
raise ValidationError('可提交人员%s' % user_ids)
if record.submitter.id not in user_ids:
raise ValidationError('您不可以提交该单据,请联系总部')
age_bs = 16 #2019.11.09,王辉、吴春亚沟通后将年龄标准由18岁调整为17岁;2019.12.06,吴春亚沟通后将年龄标准由17岁调整为16岁;2020.07.22汪莉彬邮件说将年龄由16岁改为18岁;2020.08.03汪莉彬邮件要求将年龄由18岁改为16岁
if record.birth_date and record.estimated_onboard_date:
if record.applicant_id.birth_date and record.estimated_onboard_date:
a = int(record.birth_date[:4])
a = int(record.applicant_id.birth_date[:4])
b = int(record.estimated_onboard_date[:4])
c = int(record.birth_date[5:7])
c = int(record.applicant_id.birth_date[5:7])
d = int(record.estimated_onboard_date[5:7])
e = int(record.birth_date[8:])
e = int(record.applicant_id.birth_date[8:])
f = int(record.estimated_onboard_date[8:])
if b-a>age_bs:
result=True
elif b-a==age_bs and d-c>0:
result=True
elif b-a==age_bs and d-c==0 and f-e>0:
result=True
elif b-a==age_bs and d-c==0 and f-e==0:
result=True
else:
raise ValidationError('不满16周岁')
elif record.organization_unit.department_code != record.job_id.department_id.department_code:
raise ValidationError('组织单元与岗位不匹配')
elif record.employee_number and record.identification_number:
history_departure_obj = env['history.departure'].search([('identification_id','=', record.identification_number),('active','=',True)],order='departure_date desc',limit=1)
employee_obj = env['hr.employee'].search([('identification_id','=', record.identification_number),('active','=',True)])
if history_departure_obj:
if history_departure_obj.employee_number != record.employee_number:
raise ValidationError('员工编号错误,无法提交!')
if employee_obj:
if employee_obj.employee_number != record.employee_number:
raise ValidationError('员工编号错误,无法提交!')
result = True
if record.x_cqwrz == 'A02':
result = False
user_group_code = ['R008','R009','R133','R229','R081','R173']
eroad_ids = env ['eroad.role'] .search( [('code','in',user_group_code)] )
user_ids = []
for eroad in eroad_ids:
if eroad.user_ids:
for user in eroad.user_ids:
user_ids.append(user.id)
raise ValidationError('可提交人员%s' % user_ids)
if record.submitter.id not in user_ids:
raise ValidationError('您不可以提交该单据,请联系总部')
age_bs = 16 #2019.11.09,王辉、吴春亚沟通后将年龄标准由18岁调整为17岁;2019.12.06,吴春亚沟通后将年龄标准由17岁调整为16岁;2020.07.22汪莉彬邮件说将年龄由16岁改为18岁;2020.08.03汪莉彬邮件要求将年龄由18岁改为16岁
if record.birth_date and record.estimated_onboard_date:
if record.applicant_id.birth_date and record.estimated_onboard_date:
a = int(record.birth_date [:4] )
a = int(record.applicant_id.birth_date [:4] )
b = int(record.estimated_onboard_date [:4] )
c = int(record.birth_date [5:7] )
c = int(record.applicant_id.birth_date [5:7] )
d = int(record.estimated_onboard_date [5:7] )
e = int(record.birth_date [8:] )
e = int(record.applicant_id.birth_date [8:] )
f = int(record.estimated_onboard_date [8:] )
if b-a>age_bs:
result=True
elif b-a==age_bs and d-c>0:
result=True
elif b-a==age_bs and d-c==0 and f-e>0:
result=True
elif b-a==age_bs and d-c==0 and f-e==0:
result=True
else:
raise ValidationError('不满16周岁')
elif record.organization_unit.department_code != record.job_id.department_id.department_code:
raise ValidationError('组织单元与岗位不匹配')
elif record.employee_number and record.identification_number:
history_departure_obj = env ['history.departure'] .search( [('identification_id','=', record.identification_number),('active','=',True)] ,order='departure_date desc',limit=1)
employee_obj = env ['hr.employee'] .search( [('identification_id','=', record.identification_number),('active','=',True)] )
if history_departure_obj:
if history_departure_obj.employee_number != record.employee_number:
raise ValidationError('员工编号错误,无法提交!')
if employee_obj:
if employee_obj.employee_number != record.employee_number:
raise ValidationError('员工编号错误,无法提交!')