This question has been flagged
1 Reply
9366 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
Avatar
Discard
Best Answer

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.

Avatar
Discard
Author

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