隐藏
代码如下:
run_time_since = (datetime.now() + relativedelta.relativedelta(days=45)).strftime('%Y-%m-%d')
records = env['hr.employee'].search(cr, 1, [('work_activity','!=', 'turn_over'),('active','=', True),('activated','=',True),('is_probation','=',True),('probation_date','<=', run_time_since), ('work_activity','in', ('on_boarding','in_service'))])
val_dict = {}
if records:
for record in records:
- hr_termination = env['hr.termination'].search(cr, 1, [('employee_id','=', record),('active','=', True),('state','in', ['done'])])
- employee_dimission = env['employee.dimission'].search(cr, 1, [('employee_id','=', record),('active','=', True),('state','in', ['done'])])
- if not hr_termination and not employee_dimission:
employee = env['hr.employee'].browse(cr, 1, record)
company_id = employee.department_id.company_id.id
dep_manager = employee.dep_manager.id
department_id = employee.department_id.id
employee_id = record
employee_number = employee.employee_number
english_name = employee.first_name
job_id = employee.job_id.id
parent_id = employee.parent_id.id
probation_date = employee.probation_date
val_dict =
{
"atachment_ids":[],
"company_id":company_id,
"dep_manager":dep_manager,
"department_id":department_id,
"employee_id":employee_id,
"employee_number":employee_number,
"english_name":english_name,
"job_id":job_id,
"note":False,
"parent_id":parent_id,
"probation_date":probation_date,
"state":"draft"
}
probation_bp = env['employee.probation'].search(cr, 1, [('employee_id', '=', record),('active', '=', True)])
if not probation_bp:
probation_bp_rec = env['employee.probation'].create(cr, 1, val_dict)
显示
代码如下:
run_time_since = (datetime.now() + relativedelta.relativedelta(days=45)).strftime('%Y-%m-%d')
records = env ['hr.employee'] .search(cr, 1, [('work_activity','!=', 'turn_over'),('active','=', True),('activated','=',True),('is_probation','=',True),('probation_date','<=', run_time_since), ('work_activity','in', ('on_boarding','in_service'))] )
val_dict = {}
if records:
for record in records:
hr_termination = env ['hr.termination'] .search(cr, 1, [('employee_id','=', record),('active','=', True),('state','in', ['done'] )])
employee_dimission = env ['employee.dimission'] .search(cr, 1, [('employee_id','=', record),('active','=', True),('state','in', ['done'] )])
if not hr_termination and not employee_dimission:
employee = env ['hr.employee'] .browse(cr, 1, record)
company_id = employee.department_id.company_id.id
dep_manager = employee.dep_manager.id
department_id = employee.department_id.id
employee_id = record
employee_number = employee.employee_number
english_name = employee.first_name
job_id = employee.job_id.id
parent_id = employee.parent_id.id
probation_date = employee.probation_date
val_dict =
{
"atachment_ids":[],
"company_id":company_id,
"dep_manager":dep_manager,
"department_id":department_id,
"employee_id":employee_id,
"employee_number":employee_number,
"english_name":english_name,
"job_id":job_id,
"note":False,
"parent_id":parent_id,
"probation_date":probation_date,
"state":"draft"
}
probation_bp = env ['employee.probation'] .search(cr, 1, [('employee_id', '=', record),('active', '=', True)] )
if not probation_bp:
probation_bp_rec = env ['employee.probation'] .create(cr, 1, val_dict)