Community mailing list archives

Re: QWebException: ""'NoneType' object is not callable" while evaluating "formatLang(time.strftime('%Y-%m-%d'), date=True)"" while evaluating

Emna Ragheb
- 06/20/2015 05:50:57
Hi !

I did but I still got the same issue.

Could you please help me !



2015-06-16 13:47 GMT+01:00 Satyaprakash Mishra <>:
Hii Amna,
Use " template_id=metal_reports.report_customer_account_statement_document  "
in the 4th line of xml file.

Satya Prakash Mishra

On Tue, Jun 16, 2015 at 4:49 PM, Ragheb Amna <> wrote:
Hello community !

I've create a new qweb report in Odoo 8 when I want to print it I got this error: 
QWebException: ""'NoneType' object is not callable" while evaluating
"formatLang(time.strftime('%Y-%m-%d'), date=True)"" while evaluating
"translate_doc(doc_id, doc_model, 'lang', 'metal_reports.report_customer_account_statement_document')"
 I don't know where is the problem because everything seems ok!

here is my XML report 'report_customer_account_statement.xml' :
<?xml version="1.0" encoding="utf-8"?>
<template id="report_customer_account_statement_document">
     <t t-call="metal_reports.metal_customer_statement_layout">
        <div class="page" style="header_spacing:0px">
        <body class="container" >
        <div class="row mt32 mb32">
        <div class="col-xs-6" style="text-align:left">
        <span>Client Number :</span>
        <span t-if="o.ref">
        <span t-field="o.ref"></span>
        <div class="col-xs-6" style="text-align:right">
        <div class="row mt32 mb32" style="text-align:left">
        <p  style= "margin-bottom:0px" t-if="">
<span  t-field=""/>
<p style= "margin-bottom:0px;" t-if="o.street">
<span  t-field="o.street"/>
<p  style= "margin-bottom:0px;" t-if="o.street2">
<span  t-field="o.street2"/>
<p  style= "margin-bottom:0px;" t-if="">
<span  t-field=""/>
<t t-if="">
    ,<span t-field=""/>
<p style= "margin-bottom:0px;" t-if="o.state_id">
    <span t-field=""/>
    <t t-if="o.country_id">
,<span t-field=""/>
        <div class="row mt32 mb32" style="text-align:left;margin-top:10px;">
        <span>Account statement date : </span>
        <span t-esc="formatLang(time.strftime('%Y-%m-%d'), date=True)" />
        <table class="table table-condensed">
                        <th class="text-center">Date</th>
                        <th class="text-center">Invoice Number</th>
                        <th class="text-center">Current</th>
                        <th class="text-center">30 Days</th>
                        <th class="text-right">60 Days</th>
                        <th class="text-right">90 Days+</th>
                 <tr t-foreach="getLines(o)" t-as="line">
                        <span t-field=""/>
                        <span t-field=""/>
                        <span t-esc="formatLang(calculate_date(line['id'],digits=2)"/>
<template id="report_customer_account_statement">
    <t t-call="report.html_container">
        <t t-foreach="doc_ids" t-as="doc_id">
            <t t-raw="translate_doc(doc_id, doc_model, 'lang', 'metal_reports.report_customer_account_statement_document')"/>


and here is my .py file (''):

# -*- coding: utf-8 -*-
from openerp.osv import osv
from import report_sxw
from openerp.addons import account
import time
from datetime import date, datetime
from openerp import api, models

class customer_account_statement(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(customer_account_statement, self).__init__(cr, uid, name, context=context)
        ids = context.get('active_ids')
        partner_obj = self.pool['res.partner']
        docs = partner_obj.browse(cr, uid, ids, context)
        addresses = self.pool['res.partner']._address_display(cr, uid, ids, None, None)
            'time': time,
            'getLines': self._lines_get,
            'tel_get': self._tel_get,
            'calculate_date': self._calculate_date,
            'calcul_total': self._calcul_total,
            'addresses': addresses,
        self.context = context

    def _tel_get(self,partner):
        if not partner:
            return False
        res_partner = self.pool['res.partner']
        addresses = res_partner.address_get(, self.uid, [], ['invoice'])
        adr_id = addresses and addresses['invoice'] or False
        if adr_id:
  , self.uid, [adr_id])[0]
            return adr['phone']
            return or False
        return False

    def _lines_get(self, partner):
        moveline_obj = self.pool['account.move.line']
        movelines =, self.uid,
                                        [('partner_id', '=',,
                                        ('account_id.type', 'in', ['receivable', 'payable']),
                                        ('state', '<>', 'draft'), ('reconcile_id', '=', False)])
        if len(movelines) == 0:
            movelines = {
                'id': 0,
            movelines = moveline_obj.browse(, self.uid, movelines)
        print 'line %s' % movelines
        return movelines

    def _calculate_date(self, line, dn):
        res = {}
        id = line
        moveline_obj = self.pool.get('account.move.line')
        line_obj = moveline_obj.browse(, self.uid, id)
        d0 =
        #if lang_ids == 1:
        #    d1 = datetime.strptime(line_obj['date'], '%m/%d/%Y')
        #elif lang_ids == 2:
        d1 = datetime.strptime(line_obj['date'], '%Y-%m-%d')
        date_diff = abs((d0-d1).days)
        if dn != 90 and dn <= date_diff < dn+30:
            res = line_obj.debit or ( * -1)
        elif dn == 90 and dn <= date_diff:
            res = line_obj.debit or ( * -1)
            res = False
        return res
    def _calcul_total(self, partner):
        res = {}
        total = 0.00
        sum0 = 0.00
        sum30 = 0.00
        sum60 = 0.00
        sum90 = 0.00
        movelines = self._lines_get(partner)
        for lineid in movelines:
            if self._calculate_date(, 0):
                sum0 = sum0 + self._calculate_date(, 0)
            if self._calculate_date(, 30):
                sum30 = sum30 + self._calculate_date(, 30)
            if self._calculate_date(, 60):
                sum60 = sum60 + self._calculate_date(, 60)
            if self._calculate_date(, 90):
                sum90 = sum90 + self._calculate_date(, 90)
        total = sum0 + sum30 + sum60 + sum90
        res = {
            'total': total,
            'sum0': sum0,
            'sum30': sum30,
            'sum60': sum60,
            'sum90': sum90,
        return res
class report_account_statement(osv.AbstractModel):
    _name = 'report.metal_reports.report_account_statement'
    _inherit = 'report.abstract_report'
    _template = 'metal_reports.report_customer_account_statement'
    _wrapped_report_class = customer_account_statement
and here is my report declaration : 

<?xml version="1.0" encoding="utf-8"?>

            string="Account Statement"



I hope that there is someone who can help me because I really need to fix it ! 

Thank you !!! 


Post to:

Post to: