I want to assign a employee to a task:
request.env['project.task'].sudo().with_context(check_move_validity=False).create({
'name': task['name'],
'description': task['desc'],
'project_id': project_id,
'user_id': get_or_create_employee('John Doe')
})
def get_or_create_employee(employee_name):
e_exists = request.env['hr.employee'].search([('name', '=', employee_name)])
if e_exists:
employee_id = e_exists.id
else:
new_employee = request.env['hr.employee'].sudo().with_context(check_move_validity=False).create({
'name': employee_name
})
employee_id = new_employee.id
return employee_id
The new employee is created but not assigned to the task.
Instead the Administrator is assigned to the task.
I get no errors.
Thank you