Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
3 Antworten
9731 Ansichten

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
Verwerfen
Autor Beste Antwort

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


Avatar
Verwerfen
Beste Antwort

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
Verwerfen
Autor

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?

Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Okt. 15
23005
1
Dez. 20
6604
1
März 15
7833
1
Apr. 25
1081
2
März 25
1238