定时任务每日更新当天入职的员工的试用期结束日期:
today = datetime.today().strftime('%Y-%m-%d') records = env['hr.employee'].search(cr, 1, [('hiredate', '=', today)]) for record in records: employee = env['hr.employee'].browse(cr, 1, record) if employee.x_contract_deadline: if employee.x_contract_deadline.x_code=='1': reltive_time = relativedelta.relativedelta(months=1,days=1) elif employee.x_contract_deadline.x_code=='2': reltive_time = relativedelta.relativedelta(months=2,days=1) elif employee.x_contract_deadline.x_code in ('3','4'): reltive_time = relativedelta.relativedelta(months=3,days=1) else: continue trail_end = datetime.strptime(employee.hiredate,'%Y-%m-%d') + reltive_time employee.write(
)
[试用期结束日期=入职日期+合同期限]; 通过入职日期和合同期限自动计算,即合同期限为1 year 则试用期为1个月,2 year 2个月,3 year 、unlimited 为6个月,其他 不计算