تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
4 الردود
4580 أدوات العرض

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"/>
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
4
مارس 21
10914
2
نوفمبر 21
7690
1
أبريل 20
6920
2
فبراير 20
7783
2
يناير 20
4999