Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
9838 Visualizzazioni

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
Abbandona
Autore Risposta migliore

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


Avatar
Abbandona
Risposta migliore

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
Abbandona
Autore

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?

Post correlati Risposte Visualizzazioni Attività
2
ott 15
23115
1
dic 20
6705
1
mar 15
7926
1
apr 25
1230
2
mar 25
1393