today = datetime.today().strftime('%Y-%m-%d')
employees = env['hr.employee'].search(cr,1,['|',('hiredate','=',today),('departure_time','=',today)])
for employee in employees:
record = env['hr.employee'].browse(cr,1,employee)
rec = env['x_data_employee_report'].search(cr,1,[('x_employee_id','=',record.id)])
if rec:
rec1 = env['x_data_employee_report'].browse(cr,1,rec)
rec1.write(
{'x_hire_date':record.hiredate,
'x_departure_date':record.departure_time,
'x_location_name':record.location_id.name}
)
else:
vals=
{
'x_employee_id':record.id,
'x_departure_date':record.departure_time,
'x_hire_date':record.hiredate,
'x_location_name':record.location_id.name
}
env['x_data_employee_report'].create(cr,1,vals)