No suitably rooted paths error when trying to set action on object
Action ID root
The error is informing of attempting  to link an action which expects to be for a material onto an object.
The created action from keyframing property of  a material has 'MATERIAL' set as its ID root.

ID root
Type of ID block that action can  be used on - DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING

Py console example
&gt;&gt;&gt; source = C.object
&gt;&gt;&gt; mat = source.active_material
&gt;&gt;&gt; mat
bpy.data.materials['Material']

&gt;&gt;&gt; action = mat.animation_data.action
&gt;&gt;&gt; action
bpy.data.actions['MaterialAction']

&gt;&gt;&gt; action.id_root
'MATERIAL'

An object's action  would expect this value to be 'OBJECT'.
Material action -&gt; Object action
Example, material action with only keyframes for  diffuse_color of material
&gt;&gt;&gt; for f in action.fcurves:
...     f.data_path, f.array_index
...     
('diffuse_color', 0)
('diffuse_color', 1)
('diffuse_color', 2)
('diffuse_color', 3)

the data path from an object to &quot;viewport color&quot; is  color
At the very simplest, could as above copy the action, iterate over the fcurves, make our necessary datapath change, set object id root  and assign to the object.
action = action.copy()
for fc in action.fcurves:
    fc.data_path.replace(&quot;diffuse_color&quot;, &quot;color&quot;)
action.id_root = 'OBJECT' 

Context
Customary in blender is to use the active object as a source and other selected objects as the destination.
source = context.object
targets = context.selected_objects
targets.remove(source)

for operators, having a poll method removes the need to test for  context.object being None