user = env["res.users"].search([("login", "=", "demo.student")], limit=1) if user: student = env["education.student"].search([], limit=1) if student: student.write({"portal_user_id": user.id}) env.cr.commit() print("LINKED STUDENT ID:", student.id, "TO USER ID:", user.id) else: print("NO STUDENT FOUND") else: print("NO USER FOUND") print("USER:", user.id) print("USER STUDENT:", user.student_id.id) print("STUDENT NAME:", user.student_id.full_name)