Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

QWeb Report Can't Access Company Fields

By
C S
on 11/16/16, 11:30 AM 117 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>

0

Axel Mendoza

--Axel Mendoza--
10205
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 11/16/16, 2:36 PM

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;"/>

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?

C S
on 11/17/16, 7:46 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/16/16, 11:30 AM
Seen: 117 times
Last updated: 11/16/16, 2:36 PM