Hi,
To use an image in xlwt report odoo, you have to save that image in a location first, then plot it in xls report using the xlwt functions. But in xlsxwriter this is different, you can use the image buffer directly.
eg:
company_id = request.env.user.company_id
binaryData = company_id.logo
data = base64.b64decode(binaryData)
# create a temporary file, and save the image
fobj = tempfile.NamedTemporaryFile(delete=False)
fname = fobj.name
fobj.write(data)
fobj.close()
# open the image with PIL
try:
im = Image.open(fname)
# do stuff here
finally:
# delete the file when done
os.unlink(fname)
# im = BytesIO(data)
# im = Image.frombuffer('RGBA', [1080, 1920] , binaryData, "raw", 'RGBA', 0, 1)
image_parts = im.split()
r = image_parts[0]
g = image_parts[1]
b = image_parts[2]
img = Image.merge("RGB", (r, g, b))
fo = BytesIO()
img.save(fo, format='bmp')
worksheet.insert_bitmap_data(fo.getvalue(), 0, 0)
Here I took the company logo to print in xls, change the image file accordingly.
@Anand Patel, i'm also looking for a solution. I think this can be accomplished with Aeroo, Jasper, or other reporting systems that have modules ported to 8.0, however I have not managed to get any of these solutions working in 8.0 at this point in time. I'll post back if I have more information.
--
Anand Patel
+91 9601663735