Unable to call python Function in Webkit report Openerp
Question: My report file contains

    
    
    class AccountInvoice_Report(report_sxw.rml_parse):
    
        def __init__(self, cr, uid, name, context):
    
            super(AccountInvoice_Report, self).__init__(cr, uid, name, context=context)
    
            self.localcontext.update({
    
            'time': time,
            'cr':cr,
            'uid': uid,
            'get_address': self.get_address,
        })
    

and I have written get_address function. when i call that function in my mako
file as

    
    
        <% get_address() %>
    

Then it gives Error as

    
    
       File "memory:0xb23c67ccL", line 208, in render_body
       <% get_address()%>
       TypeError: 'Undefined' object is not callable
    

What mistake I am doing file defining or calling the function.


Answer: **my_parser.py**

    
    
    import time
    from openerp.report import report_sxw
    
    class AccountInvoice_Report(report_sxw.rml_parse):
    
        def __init__(self, cr, uid, name, context):
            super(AccountInvoice_Report, self).__init__(cr, uid, name, context=context)
            self.localcontext.update({
                                      'time': time,
                                      'cr':cr,
                                      'uid': uid,
                                      'get_address': self.get_address,})
        def get_address(self):
            #your code
            return 'address'
    
    report_sxw.report_sxw('report.your_report_name', 'model', 'path/to/mako', parser=AccountInvoice_Report)
    

Include this parser in `__init__.py`

    
    
    import my_parser
    

also don't forget to import your report folder in main `__init__.py`

