Odoo Help


call function in report

Voathnak Lim
on 9/12/13, 7:49 AM 3,393 views


I want to make a simple call function from rml but does not work. could anyone help me please...

this is my .py file:

import time

from openerp.report import report_sxw

class sellsheet(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(sellsheet, self).__init__(cr, uid, name, context=context)
            'time': time,
            'test': self._testfunc,
            'foo' : "this is test",
    def _testfunc(self):
        return "this the test text."

report_sxw.report_sxw('report.product.sellsheet', 'product.product', 'addons/product_extensions/report/product_sellsheet.rml', parser=sellsheet, header=False)

and here is the rml file:

<drawString x="110" y="-251">[[ test() ]]</drawString>

here is my __init__.py of report:

import product_sellsheet

and here is my __init__.py of module:

import product_extensions
import report

and it's show error in log:

openerp.tools.safe_eval: Cannot eval 'test()'
Traceback (most recent call last):
  File "/opt/openerp/server/openerp/tools/safe_eval.py", line 241, in safe_eval
    return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "", line 1, in <module>
NameError: name 'test' is not defined

I have tested my .py file is called. but I'm not sure my __init__() function will execute or not. but I guest not. and I think this is the problem.

Your code looks good. Seems that somehow your parser is not called. I would debug it and check whether your __init__() function is executed.

Andreas Brueckl
on 9/13/13, 8:23 AM

Hello Andreas, I think my __init__() have never been call! , so what can I do to fix that?

Voathnak Lim
on 9/15/13, 11:31 PM

You can check whether the report 'report.product.sellsheet' exists more that once in the addons path.

Andreas Brueckl
on 9/16/13, 5:24 AM

Thanks you Andreas, But where can i check that? in the database or in the files.

Voathnak Lim
on 9/16/13, 10:32 PM
Voathnak Lim
On 9/18/13, 1:51 AM

I've found the solution. and It's worked. by declare the sellsheet class.

class sellsheet(osv.osv):
    print "sellsheet_class"    

So if i want 2 function do i need to code 2 different classes and on which place should i code?

Amit Patel
on 12/9/13, 4:02 PM

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




Sudhir Arya
ERP Harbor Consulting Services
Sudhir Arya (ERP Harbor Consulting Services)
On 9/14/13, 6:10 PM

Make sure your report py file is imported in __init__.py file.

Hello Sudhir, I can't see anything wrong with my __init__.py file.

Voathnak Lim
on 9/15/13, 10:47 PM

Thank you Sudhir, I have tested my .py file is called. but I'm not sure my __init__() function will execute or not. but I guest not. and I think this is the problem. do you have any idea about this?

Voathnak Lim
on 9/15/13, 11:56 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

0 follower(s)


Asked: 9/12/13, 7:49 AM
Seen: 3393 times
Last updated: 3/16/15, 8:10 AM