Skip to Content
Menu
This question has been flagged

Hello there,

We are on Odoo 8.

I wrote a module to manage Facebook an Twitter metatags. My module works well with the frontend when I share a link on these social network.

My problem is when I try to print an invoice, a sale order or an other PDF from the backend. I get the below error.

In my module, my layout inherits website.layout (see below). It seems that this website.layout is also used to print PDF reports in the backend.

Question :

How could I use a t-if condition in my code to detect when Odoo is printing a report? 

or

How could I call my new code only on the front-end? Not when printing a report.


Thanks for your help!


My module code :

        <template id="title_metas">
            <t t-if="not seo_site_name">
                <t t-set="seo_site_name" t-value="website.name" />
            </t>
         [........ many codes here.......]
        </template>

        <template id="layout" inherit_id="website.layout">
            <xpath expr="//title" position="after">
                <t t-call="title_metas" />
            </xpath>
        </template>


Error :

QWebException: "'NoneType' object has no attribute 'name'" while evaluating 'website.name'



EDIT #1

For the moment, we'll use this new "t-if" condition. So, in the back-end, when we are printing a PDF report (sale order, invoice or other), our new template "title_metas" is not called and the above error is avoid.

Would you have a best way to avoid the above error?

                <xpath expr="//title" position="after">
                    <t t-if="website and website.name">
                        <t t-call="title_metas" />
                    </t>
                </xpath>




Avatar
Discard
Related Posts Replies Views Activity
5
Nov 24
30553
1
Jul 17
7938
2
Feb 19
2885
1
Jan 19
2730
1
Oct 18
4600