Hello
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)
self.localcontext.update({
'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.
Hello Andreas, I think my __init__() have never been call! , so what can I do to fix that?
You can check whether the report 'report.product.sellsheet' exists more that once in the addons path.
Thanks you Andreas, But where can i check that? in the database or in the files.