Community mailing list archives
community@mail.odoo.com
Browse archives
Design Odoo surveys limitations
Events/Surveys: Why does it need Technical Features access rights to create an event/survey?
QWebException: ""'NoneType' object is not callable" while evaluating "formatLang(time.strftime('%Y-%m-%d'), date=True)"" while evaluating
by
Emna Ragheb
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"?>
<openerp>
<data>
<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>
</span>
</div>
<div class="col-xs-6" style="text-align:right">
<span>Date:</span>
</div>
<div class="row mt32 mb32" style="text-align:left">
<p style= "margin-bottom:0px" t-if="o.name">
<span t-field="o.name"/>
</p>
<p style= "margin-bottom:0px;" t-if="o.street">
<span t-field="o.street"/>
</p>
<p style= "margin-bottom:0px;" t-if="o.street2">
<span t-field="o.street2"/>
</p>
<p style= "margin-bottom:0px;" t-if="o.city">
<span t-field="o.city"/>
<t t-if="o.zip">
,<span t-field="o.zip"/>
</t>
</p>
<p style= "margin-bottom:0px;" t-if="o.state_id">
<t t-if="o.country_id">
,<span t-field="o.country_id.name"/>
</t>
</p>
</div>
<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)" />
</div>
<table class="table table-condensed">
<thead>
<tr>
<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>
</thead>
<tbody>
<tr t-foreach="getLines(o)" t-as="line">
<td>
<span t-field="line.date"/>
</td>
<td>
<span t-field="move_id.name"/>
</td>
<td>
<span t-esc="formatLang(calculate_date(line['id'],digits=2)"/>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</div>
</t>
</template>
<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')"/>
</t>
</t>
</template>
</data>
</openerp>
and here is my .py file ('customer_account_statement.py'):
# -*- coding: utf-8 -*-
from openerp.osv import osv
from openerp.report 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)
self.localcontext.update({
'time': time,
'getLines': self._lines_get,
'tel_get': self._tel_get,
'calculate_date': self._calculate_date,
'calcul_total': self._calcul_total,
'addresses': addresses,
'docs':docs
})
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.cr, self.uid, [partner.id], ['invoice'])
adr_id = addresses and addresses['invoice'] or False
if adr_id:
adr=res_partner.read(self.cr, self.uid, [adr_id])[0]
return adr['phone']
else:
return partner.phone or False
return False
def _lines_get(self, partner):
moveline_obj = self.pool['account.move.line']
movelines = moveline_obj.search(self.cr, self.uid,
[('partner_id', '=', partner.id),
('account_id.type', 'in', ['receivable', 'payable']),
('state', '<>', 'draft'), ('reconcile_id', '=', False)])
if len(movelines) == 0:
movelines = {
'id': 0,
}
else:
movelines = moveline_obj.browse(self.cr, 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.cr, self.uid, id)
d0 = datetime.today()
#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 (line_obj.credit * -1)
elif dn == 90 and dn <= date_diff:
res = line_obj.debit or (line_obj.credit * -1)
else:
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(lineid.id, 0):
sum0 = sum0 + self._calculate_date(lineid.id, 0)
if self._calculate_date(lineid.id, 30):
sum30 = sum30 + self._calculate_date(lineid.id, 30)
if self._calculate_date(lineid.id, 60):
sum60 = sum60 + self._calculate_date(lineid.id, 60)
if self._calculate_date(lineid.id, 90):
sum90 = sum90 + self._calculate_date(lineid.id, 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"?>
<openerp>
<data>
<report
id="customer_account_statement"
model="res.partner"
string="Account Statement"
report_type="qweb-pdf"
name="metal_reports.report_customer_account_statement"
file="metal_reports.report_customer_account_statement"
/>
</data>
</openerp>
I hope that there is someone who can help me because I really need to fix it !
Thank you !!!
Amna
Follow-Ups
-
Re: QWebException: ""'NoneType' object is not callable" while evaluating "formatLang(time.strftime('%Y-%m-%d'), date=True)"" while evaluating
byEmna Ragheb -