How to create two bodies collision

I want to create two bodies collision. The two bodies are been animated in order to determine their start and finish positions. The problem is that the two bodies collapse into each other instead of colliding because of the animated mode.

After creating the two objects (and the plane) here is the code I used:

py.data.objects['Cube'].rigid_body.kinematic = True
bpy.data.objects['Cube'].location = [-5,-5,1]
bpy.data.objects['Cube'].keyframe_insert(data_path='location', frame=1)
bpy.data.objects['Cube'].location = [0,0,1]
bpy.data.objects['Cube'].keyframe_insert(data_path='location', frame=20)
bpy.data.objects['Cube'].rigid_body.kinematic = False

bpy.data.objects['Sphere'].rigid_body.kinematic = True
bpy.data.objects['Sphere'].location = [5,-5,1]
bpy.data.objects['Sphere'].keyframe_insert(data_path='location', frame=1)
bpy.data.objects['Sphere'].location = [0,0,1]
bpy.data.objects['Sphere'].keyframe_insert(data_path='location', frame=20)
bpy.data.objects['Sphere'].rigid_body.kinematic = False


This is the first frame of the scene:

This is the last frame of the scene, the sphere is located inside the cube:

Thank you very much for helping!