I made script which swap material "Link with Data to Link with OBJECT" for all material slots of active object, then assgin same material for each material-slots again. (or blender simply remove each material from changed material-slot)
import bpy my_mat =  ao = bpy.context.active_object slots = ao.material_slots for idx in range(len(slots)): my_mat.append(slots[idx].material) for sl in slots: sl.link = "OBJECT" for idx in range(len(slots)): slots[idx].material = my_mat[idx]
It work, but each material now have 2 user (One link with OBJECT, The other Link with DATA) So I hope to "Unlink" Mateiral which link with "Data"
It can be done from Properties Editor>Material Property, change link with to Data again, then Unlink Data-block, on current material-slots (DATA) then change material-slots link (Object), and assgin the material again, to correctly show current material-slot material.
but I can not find good way to do same with bpy. Swap material link with DATA or OBJECT , and can assgin material for material-slots, but is there good way to un-link material from un-necessary one?