Odoo Help

Welcome!

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

0

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

By
zilvinas
on 7/3/16, 12:59 PM 1,055 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

--Axel Mendoza--
10205
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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