Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
13705 Lượt xem

Hello Folks,


I have been creating an excel report, and want to use product images into the same report. I have used the code: worksheet.insert_image(stat_row+1, 0, order_line.product_id.image_small, {'x_scale': 0.9, 'y_scale': 0.6}) to insert the image into excel sheet created. But it fails to insert the image.


Can anyone helps me to know the same? I have many order lines for my sales orders and want images for all the products.


Many thanks in advance.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

You can add the images to excel report like this,

if product.image_medium:
product_image = io.BytesIO(base64.b64decode(product.image_medium))
sheet.insert_image(row, col, "image.png", {'image_data': product_image})

Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Checkout our module which is available on Odoo Apps with Version 14, 15 and 16.

Search on Odoo apps Module name: Add Image in Excel / xls report

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

thank you Niyas but how to resize image ?

Ảnh đại diện
Huỷ bỏ

sheet.insert_image('B1', product_image, {'x_scale': 0.6, 'y_scale': 0.8})

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 24
2572
6
thg 9 22
28369
1
thg 4 19
3319
7
thg 4 19
15166
2
thg 5 18
5967