youta
youta

Reputation: 391

Odoo report error: Qweb error maximum recursion depth exceeded

I'm trying to create a report and everything seemed fine with my code except I got this error while printing the report

Here's a part from error message:

  File "/opt/odoo8/odoo/addons/report/models/report.py", line 135, in translate_doc
    return self.translate_doc(cr, uid, doc_id, model, lang_field, template, values, context=context)
  File "/opt/odoo8/odoo/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo8/odoo/addons/report/models/report.py", line 106, in translate_doc
    doc = self.pool[model].browse(cr, uid, doc_id, context=ctx)
  File "/opt/odoo8/odoo/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo8/odoo/openerp/models.py", line 5266, in browse
    return self._browse(Environment(cr, uid, context or {}), ids)
QWebException: """"""""""""""""""""""""""""""maximum recursion depth exceeded" while evaluating
"translate_doc(doc_id, doc_model, 'user_id.partner_id.lang', 'school_erp.report_printstandard')"" while evaluating
"translate_doc(doc_id, doc_model, 'user_id.partner_id.lang', 'school_erp.report_printstandard')"" while evaluating
"translate_doc(doc_id, doc_model, 'user_id.partner_id.lang', 'school_erp.report_printstandard')"" while evaluating

and here's my code :

in report.xml:

<template id="report_printstandard">    
            <t t-call="report.html_container">
                <t t-foreach="doc_ids" t-as="doc_id">
                    <t t-raw="translate_doc(doc_id, doc_model, 'user_id.partner_id.lang', 'school_erp.report_printstandard')"/>
                </t>
            </t>
        </template>

and here's my module:

class school_standard(osv.osv):
    _name = 'school.standard'
    _rec_name = "code"  
    _columns = {
        'name':fields.char('Standard Name', size=256, required=True),
        'code':fields.char('Standard Code', size=8, required=True),
        'user_id':fields.many2one('res.users', 'User'),     
        'student_line':fields.one2many('school.student', 'standard_id', 'Students'),
    }   
    def get_uid(self, cr, uid, context=None):
        return uid
    _defaults = {
        'user_id': get_uid,
    }
school_standard()

What is wrong in my code?

Upvotes: 1

Views: 781

Answers (2)

DASADIYA CHAITANYA
DASADIYA CHAITANYA

Reputation: 2892

You are facing the issue which is the Qweb error maximum recursion depth exceeded because of you are passing the wrong args on translate_doc method and you are trying to passing the same id which are having the template on translation mechanism not to used the template of qweb report.

translate_doc() works some things like :

Helper used when a report should be translated into a specific lang

<t t-foreach="doc_ids" t-as="doc_id">
    <t t-raw="translate_doc(doc_id, doc_model, 'user_id.partner_id.lang', account.report_invoice_school_erp.report_printstandard_documentdocument')"/>
 </t>

Parameters of translate doc function :

1. param doc_id: id of the record to translate

2. param model: model of the record to translate

3. param lang_field': field of the record containing the lang

4. param template: name of the template to translate into the lang_field

I hope my answer may helpful for you :)

Upvotes: 1

Kenly
Kenly

Reputation: 26738

You are using the same id <template id="report_printstandard"> from 'school_erp.report_printstandard'.
You shoud create a new template with different id:

<template id="report_printstandard_document">
    <t t-call="report.external_layout">
        <div class="page">
            <!-- Your Code-->
        </div>
    </t>
</template>

<template id="report_printstandard">    
    <t t-call="report.html_container">
        <t t-foreach="doc_ids" t-as="doc_id">
            <t t-raw="translate_doc(doc_id, doc_model, 'user_id.partner_id.lang', 'school_erp.report_printstandard_document')"/>
        </t>
    </t>
</template>

Upvotes: 1

Related Questions