This question has been flagged
5 Replies
27333 Views

Hello, 

I use Odoo v.10 community (10.0-20170723) and I have edited QWEB report_saleorder_document.

I need to add in a report my company logo (the same logo that I have on top-left odoo installation).

I have try to add this line in the report:

<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' %company.logo"/>

but I have, on client, the error of internal server. 

On server, the error is:

Error to render compiling AST
AttributeError: 'NoneType' object has no attribute 'logo'
Template: sale.report_saleorder_document
Path: /templates/t/t/div/div[1]/div[1]/img
Node: <img t-if="company.logo" t-att-src="'data:image/png;base64,%s' %company.logo" data-oe-id="671" data-oe-model="ir.ui.view" data-oe-field="arch" data-oe-xpath="/t[1]/t[1]/div[1]/div[1]/div[1]/img[1]"

How I can solve it?

Before this line, in my QWEB, I have a call of

<t tcall="report.external_layout">

I need another call?

Thanks

Avatar
Discard
Best Answer

You can use doc.company_id or res_company for company logo:

Like

<img t-if="res_company.logo" t-att-src="'data:image/png;base64,%s' %res_company.logo"/>
OR
<img t-if="doc.company_id.logo" t-att-src="'data:image/png;base64,%s' %doc.company_id.logo"/>

Avatar
Discard

In your code, <t tcall="report.external_layout"> replace with <t t-call="report.external_layout">

Best Answer
<div style="width: 45%;">
<img t-att-src="image_data_uri(o.company_id.logo)"/></div>
Avatar
Discard
Best Answer

Hi,

You can add the company logo to report using this,

<div style="width: 45%;float: left;">
    <img src='/web/binary/company_logo' style="width:100%"/>
</div>
Avatar
Discard
Author Best Answer

Thanks a lot, 

works all solutions!!!

Enjoy!!!

Avatar
Discard