This question has been flagged
3 Replies
6776 Views

Hello,

I want to display image of the product of sale order line in excel report using xlwt/python.

But not able to find the way. So anybody has solution then please help me.

Thanks in advance for your help!!!

Avatar
Discard

@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.

Hi Luke,

Please share if you found any solution for this.
I will do the same if i found.

Thanks,

On Wed, Sep 24, 2014 at 9:28 AM, Luke <luke-weairsoft-com@mail.odoo.com> wrote:

@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.

--
Luke
Sent by OpenERP S.A. using Odoo about Forum Post How to display image of the product of sale order line in excel report using xlwt/python



--
Thanks,

Anand Patel
+91 9601663735

Best Answer

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.

Avatar
Discard

Nice Solution hilar