Source code for odoo_xmlrpc_twisted.support.support_get_picture_string
"""Supporting program to test the module :func:`odoo_xmlrpc_twisted.functions.get_picture_string`."""importsysimportosimportbase64# Add functions directory to path for importing custom modulessys.path.append(os.path.join(os.path.dirname(__file__),'..','functions'))fromget_picture_stringimportget_picture_string# Set the name and path of the resulting image filecurrent_path=os.path.dirname(os.path.realpath(__file__))filename='picture_get_picture_string.png'fullpath=os.path.join(current_path,filename)
[docs]defsupport_get_picture_string(custom_product_id,custom_res_field,custom_name):""" Function to test the module "get_picture_string" The result from that function will be save as a "PNG" image file to check if "get_picture_string" works as expected. """# call the function "get_picture_string" to get the picture stringremoved_custom_datas=get_picture_string(custom_product_id,custom_res_field,custom_name)# converting the picture from a base64 stringimage_str=base64.b64decode(removed_custom_datas)# save it as a picture in the actual path withopen(fullpath,'wb')asimageFile:imageFile.write(image_str)return(filename)