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.

0

TypeError: 'Undefined' object is not callable

By
Muaz
on 1/15/14, 5:51 AM 3,259 views

my report.py

import time
from openerp import report
 from openerp.osv import osv
import openerp.pooler
from openerp.report import report_sxw
from openerp.osv import osv,fields
from openerp.tools.translate import _
from openerp.tools import amount_to_text_en

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

def _get_iec_accounts(self, obj):

     payslip_line = self.pool.get('account_move_line')
     payslip_lines = []  
     res = []
     self.cr.execute("SELECT pl.account_id "\
                    "pl.sum(debit) as debit"\
                    "pl.sum(credit) as credit"\
                    "pl.name","pl.date"\
                    " from account_move_line as pl"\
                    "WHERE (date_from >= %s) AND (date_to <= %s)"\
                    "ORDER BY pl.account_id",
                    (self.date_from, self.date_to))
     payslip_lines = [x[0] for x in self.cr.fetchall()]
     for line in payslip_line.browse(self.cr, self.uid, payslip_lines):
        res.append({                
            'name': line.account_id.name

        })         
     return res

   report_sxw.report_sxw('report.iec.account.report.webkit',
                  'account.account',
                  '/addons/iec_report_account/report/iec_report_webkit.mako', parser=iec_account_report_webkit)
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

my mako template:

 <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head>
<style type="text/css">
    ${css}
   </style>

</head>
<body>
%for o in objects:
<table  width="100%">
        <tr>
            <td style="text-align:center;">
                <h3><b> Mako </b></h3>
            </td>
        </tr>
</table>

 <table width="100%" style="font-weight: bold ;font-size: 12px ;border-bottom:1px solid black;">  
    <tr>
        <td width="60%">
            ${_('Account Name') }
        </td>
        <td width="10%">
            ${_('Debit') }
        </td>
        <td width="10%">
            ${_('Credit') }
        </td>                      
    </tr>
  </table>


    %for account in (get_iec_accounts(o)):
    <tbody>
    <tr>

            <td width="60%" >${account['name']}</td>
            <td width="10%" style="text-align:right;">${account['debit']}</td>
            <td width="10%" style="text-align:right;">${account['credit']}</td>

    </tr>
    </tbody>
    %endfor 
</table> 
%endfor
 </body>
 </html>

when i print show this error:

 Webkit render!

     Traceback (most recent call last):
    File "C:\Program Files (x86)\OpenERP 7.0-20131206-         002433\Server\server\openerp\addons\report_webkit\webkit_report.py", line 273, in create_single_pdf

 File "mako\template.pyc", line 302, in render

File "mako\runtime.pyc", line 660, in _render

 File "mako\runtime.pyc", line 692, in _render_context

File "mako\runtime.pyc", line 718, in _exec_template

  File "memory:0x36872f0", line 34, in render_body
   %for account in (get_iec_accounts(o)):
  TypeError: 'Undefined' object is not callable
0

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 1/17/14, 5:03 PM

Muaz,

Use %for account in get_iec_accounts(o):

I believe you even need not to pass any arg as you don't use in method!

Thanks.

pales help me, how can i pass arg to my method. i want to make report by range date

Muaz
on 1/17/14, 6:09 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 1/15/14, 5:51 AM
Seen: 3259 times
Last updated: 3/16/15, 8:10 AM