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

Why is my custom QWeb report giving a QWebTemplateNotFound error?

By
Yenthe
on 12/16/14, 3:25 AM 3,287 views

Hi everybody

I'm trying to figure out what is the correct way to create a new report in Odoo 8, but I don't get it 100% correct.

What I now have is the following..
sale/sale_report.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <report 
            id="report_sale_order"
            string="Quotation / Order"
            model="sale.order" 
            report_type="qweb-pdf"
            file="sale.report_saleorder" 
            name="sale.report_saleorder" 
        />
        <report 
            id="report_opleveringsattest_id"
            string="Opleveringsattest"
            model="res.partner" 
            report_type="qweb-pdf"
            file="sale.report_opleveringsattest" 
            name="sale.report_opleveringsattest" 
        />
    </data>
</openerp>

sale/views/report_opleveringsattest.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_opleveringsattest_document">
    <t t-call="report.external_layout">
        <div class="page">
            <div class="oe_structure"/>
            <div class="row">
                <div class="col-xs-6">
                    <p>TEST</p>
                </div>
            </div>
            <div class="oe_structure"/>
        </div>
    </t>
</template>

<template id="report_opleveringsattest">
    <t t-call="report.html_container">
        <t t-foreach="doc_ids" t-as="doc_id">
            <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_opleveringsattest_document')"/>
        </t>
    </t>
</template>
</data>
</openerp>

But then I get the error "SyntaxError: JSON.parse: unexpected end of data at line 2 column 1 of the JSON data"..
Which then tells me

QWebTemplateNotFound: External ID not found in the system: sale.report_opleveringsattest

With kind regards
Yenthe
 

1
Harsh Dhaduk
On 12/16/14, 8:15 AM

Hi Yenthe,
You can try this.

In sale/views/report_opleveringsattest.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_opleveringsattest_document">

    <t t-call="report.html_container">
        <t t-foreach="docs" t-as="o">
            <t t-call="report.external_layout">
                <div class="page">
                    <h2>TeSt</h2>
        </div>
            </t>
        </t>
    </t>
</template>

<template id="report_opleveringsattest">
    <t t-call="report.html_container">
        <t t-foreach="doc_ids" t-as="doc_id">
            <t t-raw="translate_doc(doc_id, doc_model, ''commercial_partner_id.lang', 'sale.report_opleveringsattest_document')"/>
        </t>
    </t>
</template>
</data>
</openerp>

 

And sale/sale_report.xml

<report
    id="report_opleveringsattest_id"
    string="Opleveringsattest"
    model="res.partner"
    report_type="qweb-pdf"
    file="sale.report_opleveringsattest"
    name="sale.report_opleveringsattest"
/>

 

And finally add the xml files in __openerp__.py like this:

    'data': [
        //other imports are here
       'views/report_opleveringsattest.xml',
       'sale_report.xml',
    ]

Thank you very much Harsh! I've been so free to edit your answer to fill up a few more details and format it a bit for people in the future. I've both accepted and upvoted your answer as this helped me A LOT. Thanks!

Yenthe
on 12/16/14, 8:50 AM

@Harsh, do you happen to know how I can get the customer his name etc in this report now? I can't seem to access it with just

Yenthe
on 12/16/14, 8:57 AM

If anybody wants to know this you'll need to do a foreach and then print it out with for example.

Yenthe
on 12/16/14, 9:31 AM

Yes you can simple use o.name and other fields access using "o"

Harsh Dhaduk
on 12/16/14, 11:48 PM
0
Thomas Fossoul
On 12/16/14, 3:45 AM

like the same way odoo do it on its module.

Check the following file in the account module :

account_report.xml

views/report_invoice.xml

That's all :)

 

 

@Thomas, I've updated my question so you can see the code.. in my view it looks like I have everything I need then? What is the reason there is no printing option being showed?

Yenthe
on 12/16/14, 4:05 AM

@Thomas, nevermind I asked for the wrong model on the report. Alright the option is showing up now but when I print I get the error "SyntaxError: JSON.parse: unexpected end of data at line 2 column 1 of the JSON data" any clue on this?

Yenthe
on 12/16/14, 4:08 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

2 follower(s)

Stats

Asked: 12/16/14, 3:25 AM
Seen: 3287 times
Last updated: 3/16/15, 8:10 AM