Skip to Content
Menu
This question has been flagged
1 Reply
12887 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!

Avatar
Discard
Best Answer

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"/>
Avatar
Discard
Author

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.

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

Author

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.

Related Posts Replies Views Activity
0
Oct 24
118
1
Apr 24
972
7
Sep 24
22461
1
Mar 24
278
0
Feb 24
421