Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ

I want to open the attachment in the same screen as an image preview.

Python code:

attachment_ids = fields.Many2many('ir.attachment', 'purchase_order_line_attachment_rel', string='Attachments',
                                      attachment=True, copy=False, ondelete="restrict")
                                      

'attachments': [(attachment_id.name, attachment_id.datas, attachment_id.id, attachment_id.mimetype) for attachment_id in
                                    order.attachment_ids],
                                

xml template code:


   
<templates id="template" xml:space="preserve">
...
<t t-foreach="t.attachments" t-as="attachment">
        <t t-if="attachment">
            <a t-att-href="'/web/content/' + attachment[2] + '?download=true'">
            <div class="oe_attachment_embedded o_image"
                 title="attachment[0]"
                 data-mimetype="application/pdf"></div>
                <span t-esc="attachment[0]"/>
            </a>
        </t>
</t>

   

...


   

</templates>





Above code open attachment in new tab as download whereas i want to open the attachment in the same screen as an image preview.

I am using odoo v16

Thanks in advance




Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 23
406
0
thg 9 19
3710
1
thg 8 17
3036
1
thg 4 25
772
1
thg 3 24
1588