Skip to Content
Menu
This question has been flagged
2 Replies
11573 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
 

Avatar
Discard
Best Answer

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',
    ]

Avatar
Discard
Author

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!

Author

@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

Author

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

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

Best Answer

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 :)

 

 

Avatar
Discard
Author

@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?

Author

@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?