Odoo Help


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.


RuntimeError: maximum recursion depth exceeded

on 6/3/13, 8:10 AM 5,454 views

Hi guyz, I'm getting this error: RuntimeError: maximum recursion depth exceeded. But the code was working fine before sometime.

When I searched regarding this issue, many results pointed to execution time taken due to python and also explanations were difficult to understand.

Can anyone give me suggestion regarding this error.

In sample.py:

from osv import fields, osv
import time

class sample(osv.osv):
    def onchange_state(self, cr, uid, ids, state_id, context=None):
        if state_id:
            country_id = self.pool.get('res.country.state').browse(cr, uid, state_id, context).country_id.id
            return {'value':{'country_id':country_id}}
        return {}   
    def _calculate(self, cr, uid, ids, fields, arg, context):
        for record in self.browse(cr, uid, ids):
            x[record.id]= record.field_a + record.field_b
        return x
    _name = "sample"
    _table = "sample"
    _rec_name = "name"
    _log_access = True
    _description = "Simple Form"
    _columns = {
             'name':fields.char('Name', size=32, required=True),
             "age" : fields.integer("age"),
             "length": fields.integer("length"),    
             'address': fields.text('Address'),
             'flag': fields.boolean('Flag'),
             'date': fields.date('Date'),
             'datetime': fields.datetime('Date with Time'),
             'confirm': fields.selection((('unconfirmed', 'Unconfirmed'), ('confirmed', 'Confirmed')),
                  'Selection Box'),
             'image': fields.binary("Image"),
             "phone" : fields.char("phone"),

             'user_id': fields.many2one('res.users', 'Salesperson'),
             'partner_id': fields.many2one('res.partner', 'Customer', ondelete='cascade'),
             'location_id' : fields.related('location_id', type="many2one", relation="stock.location", string="Location Id"),
             'state_id': fields.many2one("res.country.state", 'State'),
             'country_id': fields.many2one('res.country', 'Country'),
             'country': fields.related('country_id', type='many2one', relation='res.country', string='Country'), 

             'duration' : fields.float('Duration'),

             'field_a' : fields.integer('Number1') ,
             'field_b' : fields.integer('Number2'),
             'result'  : fields.function(_calculate, type='integer', obj='sample', method=True, store=False, string='Result'),

    _defaults = {  
        'date': fields.date.context_today,


In sample_view.xml:

<?xml version="1.0" encoding="UTF-8"?>

        <record model="ir.ui.view" id="test_tree_view">
            <field name="name">test.tree</field>
            <field name="model">sample</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="test" toolbar="1">
                    <field name="name" />
                    <field name="age" />
                    <field name="date" />

        <record model="ir.ui.view" id="test_form_view">
            <field name="name">test.form</field>
            <field name="model">sample</field>
            <field name="arch" type="xml">
                <form string="test" version="7.0">

                        <button name="header_button" string="Create" type="object" />
                        <field name="confirm" widget="statusbar" statusbar_visible="unconfirmed,coked"
                            clickable="True" />
                        <!-- <field name="name" widget="statusbar" statusbar_visible="draft,sent,invoiced,done" 
                            statusbar_colors='{"draft":"red","done":"blue"}' /> -->

                            <label string="Label" colspan="2" />
                            <field name="name" select="1" />
                            <field name="state_id" string="State" onchange="onchange_state" />
                            <field name="country_id" string="Country" />
                            <field name="country" />
                            <field name="location_id" /> 
                            <separator string="seperator tag inserted here"
                                colspan="4" />
                            <newline />
                            <notebook colspan="4" tabpos="up">
                                <page string="basic data field">
                                        <field name="age" select="2" />
                                        <field name="length" select="3" />
                                        <field name="address" placeholder="Provide current address..." />
                                        <field name="flag" />
                                        <field name="date" />
                                        <field name="datetime" />
                                        <field name="confirm" />
                                        <field name="image" />
                                        <field name="state_id" />
                                        <field name="country_id" />
                                <page string="relational data field">
                                        <field name="user_id" string="user_id(many2one)" />
                                        <!-- <field name="partner_ids" string="partner_ids(one2many)" /> -->
                                <page string="functional data field">
                                        <field name="field_a" />
                                        <field name="field_b" />
                                        <field name="result" />
                                <page string="calendar">
                                        <field name="user_id" string="conducted by" />
                                        <field name="datetime" string="scheduled date" />
                                        <field name="duration" />
                                        <field name="partner_id" string="member to attend" />

                        <!-- <button name="Submit" string="Button" icon="STOCK_APPLY" special="save" 
                            colspan="2" type="action" target="new" confirm="Ask for Confirmation" /> -->


        <record model="ir.ui.view" id="sample_kanban_view">
            <field name="name">Kanban</field>
            <field name="model">sample</field>
            <field name="arch" type="xml">
                    <field name="name" />
                    <!-- <field name="code" /> <field name="lst_price" /> -->
                        <t t-name="kanban-box">
                            <div class="oe_kanban_vignette oe_semantic_html_override">
                                <a type="open">
                                    <img t-att-src="kanban_image('sample', 'image', record.id.value)"
                                        class="oe_kanban_image" />
                                <div class="oe_kanban_details">
                                        <a type="open">
                                            <!-- <t t-if="record.code.raw_value"> [ <field name="code" /> 
                                                ] </t> -->
                                            <field name="name" />
                                    <div name="tags" />
                                            <field name="age"></field>

        <record model="ir.ui.view" id="sample_graph">
            <field name="name">sample.graph</field>
            <field name="model">sample</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph string="Graph string" orientation="horizontal" type="bar">
                    <field name="name" group="True" />
                    <field name="age" operator="*" />

        <record model="ir.ui.view" id="sample_calendar_view">
            <field name="name">sample.calendar</field>
            <field name="model">sample</field>
            <field name="type">calendar</field>
            <field name="arch" type="xml">
                <calendar string="Reminders" date_start="datetime" color="user_id"
                    date_delay="duration" mode="week">
                    <field name="name" modifiers="{'required': true}" />
                    <field name="partner_id" modifiers="{}" />

        <record model="ir.ui.view" id="sample_search_view">
            <field name="name">sample.search</field>
            <field name="model">sample</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                    <group expand="1" string="Group By...">
                        <filter string="Users" icon="terp-project" domain="[]"
                            context="{'group_by':'user_id'}" />
                        <filter string="Partner" icon="terp-project" domain="[]"
                            context="{'group_by':'partner_id'}"  />
                        <separator orientation="vertical" />
                        <filter string="Date" icon="terp-project" domain="[]"
                            context="{'group_by':'date'}" />
                        <filter string="Current State" domain="[('confirm','in',('unconfirmed','confirmed'))]" help="Confirmed and Unconfirmed Tasks" icon="terp-project"/>
                        <field name="location_id" string="Location"
                            filter_domain="['|',('location_id','ilike',self),('location_dest_id','ilike',self)]" />

        <record model="ir.ui.view" id="sample_gantt_view">
            <field name="name">sample.gantt</field>
            <field name="model">sample</field>
            <field name="type">gantt</field>
            <field name="arch" type="xml">
                <gantt color="user_id" date_delay="duration" date_start="datetime"
                    string="Tasks" mode="3months">
                    <level object="crm.make.sale" link="partnet_id" domain="[]">
                        <field name="name" />

        <record model="ir.actions.act_window" id="action_test_form">
            <field name="name">sample</field>
            <field name="res_model">sample</field>
            <field name="view_type">form</field>
            <field name="view_mode">kanban,tree,form,graph,calendar,gantt</field>

        <menuitem name="testParent" icon="terp-project" id="testParent_menu"
            sequence="0" />

        <menuitem name="NotesChild" parent="testParent_menu" id="NotesChild_menu" />

        <menuitem name="Header" parent="NotesChild_menu" id="Header_menu_mainform"
            action="action_test_form" />



    "name" : "sample",
    "version" : "0.1",
    "author" : "Atchuthan",
    "category" : "Generic Modules/Others",
    "depends" : ["base", "stock"],
    "description" : "Simple demo form",
    "demo_xml" : [],
    "data" : ["sample_view.xml"],
    "active": False,
    "installable": True

what is the name of the module you were working with? were you working with partners, categories, or bill of materials?

on 6/3/13, 9:01 AM

i created a custom module

on 6/3/13, 9:29 AM

could you post it? looks like there is a bug in your module

on 6/3/13, 9:30 AM

code added

on 6/3/13, 9:38 AM

the code looks OK, could you post the traceback?

on 6/3/13, 9:42 AM

traceback updated

on 6/4/13, 2:40 AM

This code is working properly fine now... So why was there a error?

No code changes done.

on 6/4/13, 2:41 AM
Christian Twinckle
On 6/4/13, 2:53 AM


check this answer.may be this answer will help you.

Thank you.

I already viewed this link with OpenERP bug issues @ https://bugs.launchpad.net/openobject-addons/+bug/891474.

They are telling it as "configuration mistake" but why is it working fine now?..

I didnt change any code to remove error. Today when I tried to open my custom module, it worked fine.

on 6/4/13, 3:05 AM

Sudhir Arya (SA)

--Sudhir Arya (SA)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow




Sudhir Arya (SA)
On 6/4/13, 4:29 AM

It seems problem is in following line:

for picking, todo in self._chain_compute(cr, uid, moves, context=context).items():

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

0 follower(s)


Asked: 6/3/13, 8:10 AM
Seen: 5454 times
Last updated: 3/16/15, 8:10 AM