Well after reading the documentations it appears that writecolorbuffer is obsolete and it is advised that rendertarget should be used to obtain the information. This is the solution you just need to substitute the path variable with your output.
def create_viewport_render(self, path):
"""
Function that calls the OpenMaya Renderer module to screenshot the viewport and save it
"""
renderer = apiOMR.MRenderer
tgt_mgm = renderer.getRenderTargetManager()
texture_mgm = renderer.getTextureManager()
target = tgt_mgm.acquireRenderTargetFromScreen('MTextureTest')
target_desc = target.targetDescription()
target_data = target.rawData()
# Render Target must be released in order to avoid causing buffer issues
tgt_mgm.releaseRenderTarget(target)
# Setting parameters of the file to be output.
texture_desc = apiOMR.MTextureDescription()
texture_desc.fWidth = target_desc.width()
texture_desc.fHeight = target_desc.height()
texture_desc.fDepth = 1
texture_desc.fBytesPerRow = target_data[1]
texture_desc.fBytesPerSlice = target_data[2]
texture_desc.fMipmaps = 1
texture_desc.fArraySlices = target_desc.arraySliceCount()
texture_desc.fFormat = target_desc.rasterFormat()
texture_desc.fTextureType = 2
texture_desc.fEnvMapType = 0
texture = texture_mgm.acquireTexture('MTextureTest', texture_desc, target_data[0])
texture_mgm.saveTexture(texture, path)
# Texture must be release to avoid causing buffer issues.
texture_mgm.releaseTexture(texture)