Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
4615 มุมมอง

I've installed the Attachment module, that allow to attach filesto every module in odoo. The attachments are stored in db in the ir_attachment table. 


There is an entry for every attachment related to the id of the object, for example in the table I have:

res_model =account_invoice

res_id = 2886  (this is the id of the invoice)

index_content = 'image'



When I print the invoce I need to print also the image attached to the invoice.


Could you please give me an example of code to be used?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Try the following code if it works for you.

<t foreach="o.env['ir.attachment'].search([('res_id', '=', o.id), ('res_model', '=', 'account.invoice')])" t-as="attachment">
<span>
<img t-att-src="/web/image/ir.attachment/attachment.id/datas"/>
</span>

</t>


อวตาร
ละทิ้ง
ผู้เขียน

File "C:\Program Files (x86)\Odoo 11.0\python\lib\ast.py", line 35, in parse

return compile(source, filename, mode, PyCF_ONLY_AST)

File "<unknown>", line 1

/web/image/ir.attachment/attachment.id/datas

^

SyntaxError: invalid syntax

Error when compiling AST

SyntaxError: invalid syntax (<unknown>, line 1)

Template: account.report_invoice_document_with_payments

Path: /templates/t/t/t[2]/span/a

ผู้เขียน

Thanks a lot for your suggestion, trying the code I'm getting the attached error.

คำตอบที่ดีที่สุด

additional info try this:

<img t-if="attachment" t-att-src="'data:image/png;base64,%s' % attachment"/>
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
4
มี.ค. 21
10965
2
พ.ย. 21
7740
Adding an attachment from python แก้ไขแล้ว
1
เม.ย. 20
6962
2
ก.พ. 20
7811
2
ม.ค. 20
5043