Skip to Content
Menu
This question has been flagged
3 Replies
8458 Views

I'm trying to change the default header but every field throws a NoneType error. For example, in the code below it says QWebException: "'NoneType' object has no attribute 'logo'" while evaluating"'data:image/png;base64,%s' % company.logo"

<pre>

<template id="dropoff_confirmation_document">

<t t-call="report.html_container"> <t t-foreach="docs" t-as="o">

<t t-call="report.external_layout">

<div class="header">

<div class="row" style="border-bottom: 1px solid black;">

<div class="col-xs-3 pull-right">

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

<div t-field="company.partner_id" t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}' /> </div>

</div>

</pre>

Avatar
Discard
Author Best Answer

In the end, I ended up creating a module to inherit and edit the default header for all documents instead of just one.


Avatar
Discard
Best Answer

In Odoo QWeb templates variables resides in the qweb context, that context have all the values that you are pass to the template render and also the values generated during the rendering of the template. If you are not passing the variable company to the render of your template that error is expected. If the company variable that you are expecting is one of the objects used to render the report then you need to refer to it as "o" because that is one of the variables generated in the render of the template in the line:

<t t-foreach="docs" t-as="o">

if that is the case then you need to use it like:

<img t-if="o.logo" t-att-src="'data:image/png;base64,%s' % o.logo" style="max-height: 45px;"/>
Avatar
Discard
Author

Your solution is assuming I have those fields on my object, but I don't. Do I need to declare the res.company model to override it? I am able to inherit it and override it, but then it changes for every report. I need to somehow modify the default header and footer without overriding it for all reports. Also, how did you format your post's code in the grey boxes?

Related Posts Replies Views Activity
2
Oct 15
21419
1
Dec 20
5671
1
Mar 15
6756
4
Nov 24
5236
3
Dec 24
5722