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

How to create and use user defined functions in qweb report?

By
Stephen Raj
on 2/20/15, 8:41 AM 1,770 views

Hi,

I've designed qweb report. I couldn't call user defined functions.

 

Code:

File: report/note_notebook.py

---------------------------------------------------

from openerp.osv import osv
from openerp.report import report_sxw

class note_notebook(report_sxw.rml_parse):
    
    def __init__(self, cr, uid, name, context=None):
        super(note_notebook, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'get_text': self._get_text,
        })
        self.context = context

    def _get_text(self):
        return 'Hello World'

class report_notebookview(osv.AbstractModel):
    _name = 'report.notebook.report_notebookview'
    _inherit = 'report.abstract_report'
    _template = 'notebook.report_notebookview'
    _wrapped_report_class = note_notebook

 

File: views/report_notebookview.xml

----------------------------------------------------------------------

<template id="report_notebookview">
    <t t-call="report.html_container">
        <t t-call="report.internal_layout">
            <div class="page">
                <p>
                    <span t-esc="get_text()"/>
                </p>
            </div>
        </t>
    </t>
</template>

 

It's showing me following error when I try to print.

Error:

----------------------------------------------------------

QWebException: "'NoneType' object is not callable" while evaluating 'get_text()'

 

I don't know what I'm missing here. Please help me to complete this.

Thank you.

Probably code note_notebook.py is not executed, you have note_notebook.py in __init__.py in report folder?

zbik
on 2/20/15, 11:17 AM
-1
Alby Antony
On 2/21/15, 3:58 AM

https://www.odoo.com/forum/help-1/question/how-to-create-and-use-user-defined-functions-in-qweb-report-77108

-1
Stephen Raj
On 2/20/15, 11:23 PM

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: 2/20/15, 8:41 AM
Seen: 1770 times
Last updated: 3/16/15, 8:10 AM