Odoo Help


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

Stephen Raj
on 2/20/15, 8:41 AM 2,371 views


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



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)
            '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">
                    <span t-esc="get_text()"/>


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



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?

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


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

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 2/20/15, 8:41 AM
Seen: 2371 times
Last updated: 3/16/15, 8:10 AM