Search code examples
xmlimagereportodooqweb

How to add multiple images to a qweb report in odoo?


I want to provide an option to attach multiple images while creating a quotation and then when that is printed, it has to be displayed in the PDF report also.

I was successful in handling the above scenario with single image by this:

In py -

name = fields.Binary(string="Upload", required=False)

In XML -

<img t-attf-src="data:image/*;base64,{{doc.image_field_name}}"/>

But when it comes to multiple images, I am guessing its a little complex. Can someone guide me how to achieve this? I even tried the many2many field, but didn't work.


Solution

  • You could log a note or notes with the images attached to it and then use the field "message_ids" and get the related attachments with "message_ids.attachment_ids", then you could foreach the images logged:

    <t t-foreach="doc.message_ids.attachment_ids" t-as="attachment">
        <img t-att-src="attachment.image_src"/>
    </t>