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.

2

Cannot call a method from RML report file? [Closed]

By
Dhinesh - Technical Consultant, Sodexis Inc
on 4/10/14, 9:20 AM 2,657 views

The Question has been closed

by
Dhinesh - Technical Consultant, Sodexis Inc
on 04/30/2014 02:42:00

Cannot able to call a method checkbalance() from rml file. Error msg is below.

**Error in console: 11106 ERROR rml_report openerp.tools.safe_eval: Cannot eval 'checkbalance(val)'

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 'checkbalance' is not defined**

My module structure is

-rmlreport

-rml_report
    __init__.py
    rml_report.py
    rml_report.rml
    rml_report.sxw
__init__.py
__openerp__.py
rmlreport_report.xml
rmlreport_view.xml
rmlreport.py

Code in __init__.py inside -rml_report folder

from . import rml_report

Code in rml_report.py inside -rml_report folder

import time
from openerp.report import report_sxw

class rml_report(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(rml_report, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
            'checkbalance' : self.checkbalance
        })
    def checkbalance(self):
        return "test"


report_sxw.report_sxw('report.rml_report', 'rmlreport', 'test/rmlreport/rml_report/rml_report.rml', parser=rml_report)

Call in rml_report.rml inside -rml_report folder

[[ checkbalance() ]]

Code in __init__.py inside main module

from . import rmlreport
from . import rml_report

Code in __openerp__.py inside main module

{
"name" : "rmlreport",
"version" : "0.1",
"depends" : ['base','report_webkit'],
"description" : "rmlreport",
"data" : ['rmlreport_view.xml','rmlreport_report.xml'],
"active": True,
"installable": True

}

Code in rmlreport_report.xml under main module

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <report id="rmlreport_id" model="rmlreport" name="rmlreport" string="RML Report" rml="rmlreport/rml_report/rml_report.rml"/>
    </data>
</openerp>
3

Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
3577
| 5 4 9
Pondicherry, India
--Dhinesh - Technical Consultant, Sodexis Inc--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks. Did code in Java, PHP.

Contact me at: dvdhinesh.mail@gmail.com

Dhinesh - Technical Consultant, Sodexis Inc
On 4/15/14, 4:16 AM

Hi all i found whats wrong with my coding. I m posting that. Hope it will help someone...

Code in rml_report.py inside -rml_report folder

report_sxw.report_sxw('report.rml_report', 'rmlreport', 'test/rmlreport/rml_report/rml_report.rml', parser=rml_report)

Code in rmlreport_report.xml under main module

Wrong Coding

<report id="rmlreport_id" model="rmlreport" name="rmlreport" string="RML Report" rml="rmlreport/rml_report/rml_report.rml"/>

Changed Coding

<report id="rmlreport_id" model="rmlreport" name="rml_report" string="RML Report" rml="rmlreport/rml_report/rml_report.rml"/>

Error is name in rmlreport_report.xml file is wrong. From document -- name: the name of the report without the first "report."

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/10/14, 9:20 AM
Seen: 2657 times
Last updated: 3/16/15, 8:10 AM