Odoo Help

0

Custom Qweb report error "QWebException: "'NoneType' object is not callable""

By
zilvinas
on 7/3/16, 12:59 PM 2,191 views

Hello, i want create custom report with my custom renderer, i am using Odoo v9 community. I have error message when generating report:

QWebException: "'NoneType' object is not callable" while evaluating
"translate_doc(doc_id, doc_model, 'partner_id.lang', 'custom_module_name.report_object_review_document')"

my custom_module_name_report.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
string="Object review"
id="action_report_object_review"
model="crm.lead"
report_type="qweb-pdf"
name="custom_module_name.report_object_review"
file="custom_module_name.report_object_review"
/>
</data>
</openerp>

report_object_review.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_object_review_document">
<t t-foreach="docs" t-as="o">
</div>
<div class="page">
<div class="row">
<h3>Title</h3>
<span t-esc="get_format()"/>
</div>
</div>
</t>
</template>
<template id="report_object_review">
<t t-call="report.html_container">
<t t-foreach="doc_ids" t-as="doc_id">
<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'custom_module_name.report_object_review_document')"/>
</t>
</t>
</template>
</data>
</openerp>

custom_module_name.py

from openerp.osv import osv
from openerp import models, fields, api, _
class report_object_review(models.AbstractModel):
_name = 'report.custom_module_name.report_object_review'
_template = 'custom_module_name.report_object_review'
def get_format(self):
return 'some text!!!'
@api.multi
def render_html(self, data=None):
report_obj = self.env['report']
report = report_obj._get_report_from_name(self._template)
docargs = {
'get_format': self.get_format,
'doc_ids': self._ids,
'doc_model': report.model,
'docs': self,
}
return report_obj.render(self._template, docargs)

maybe someone can tell me what is wrong with my code?

thank in advance!

1
Axel Mendoza
On 7/3/16, 6:53 PM

Hi zilvinas

Your issue is that there is no translate_doc in Odoo v9. You need to change this:

<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'custom_module_name.report_object_review_document')"/>

to this:

<t t-call="custom_module_name.report_object_review_document" t-lang="doc_id.partner_id.lang"/>

thank you Alex! also need to mention what i have had to change line <t t-foreach="doc_ids" t-as="doc_id"> to <t t-foreach="docs" t-as="o"> and call report

<t t-call="custom_module_name.report_object_review_document" t-lang="o.partner_id.lang"/> also in .py file have had to changeline 'docs': self.env[report.model].browse(self.ids),

if you cat edit your comment, becouse i dont have enouch karma.

zilvinas
on 7/4/16, 6:12 AM

no need to change it, all depends of the vars that you are using, if you use doc_id or o, you just need to care about how you name it, but the issue is that the translate_doc is gone and now there is the lang attr for the t-call tag

Axel Mendoza
on 7/4/16, 6:26 AM

i understand that, but after changing another error was occured. my renderer returns doc_ids as int not a modelname(id) so i have had change it to 'docs' and also i have had to change render function to return docs with correct model name, because my module generates report from crm.lead module not my custom module.

zilvinas
on 7/4/16, 7:32 AM

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 7/3/16, 12:59 PM
Seen: 2191 times
Last updated: 7/4/16, 6:13 AM