RuntimeError:在运行 openerp 时调用 Python 对象时超出了最大递归深度

Posted

技术标签:

【中文标题】RuntimeError:在运行 openerp 时调用 Python 对象时超出了最大递归深度【英文标题】:RuntimeError: maximum recursion depth exceeded while calling a Python object while running openerp 【发布时间】:2014-11-18 09:17:09 【问题描述】:

请帮我纠正错误!我试图更新 odoo-openerp 模块。在控制器文件夹中 main.py 结构如下所示。我收到 RuntimeError 错误:调用 Python 对象时超出最大递归深度 :

@http.route(['/survey/submit/<model("survey.survey"):survey>'],
            type='http', methods=['POST'], auth='public', website=True)
def submit(self, survey, **post):
    _logger.debug('Incoming data: %s', post)
    page_id = int(post['page_id'])
    # cr, uid, context = request.cr, request.uid, request.context
    survey_obj = request.env['survey.survey']
    questions_obj = request.env['survey.question']
    # questions_ids = questions_obj.search(cr, uid, [('page_id', '=', page_id)], context=context)
    # questions = questions_obj.browse(cr, uid, questions_ids, context=context)
    questions = questions_obj.sudo().search([('page_id', '=', page_id)])

    # Answer validation
    errors = 
    for question in questions:
        answer_tag = "%s_%s_%s" % (survey.id, page_id, question.id)
        # errors.update(questions_obj.validate_question(cr, uid, question, post, answer_tag, context=context))
        errors.update(questions_obj.validate_question(question, post, answer_tag))

    ret = 
    if (len(errors) != 0):
        # Return errors messages to webpage
        ret['errors'] = errors
    else:
        # Store answers into database
        user_input_obj = request.env['survey.user_input']

        user_input_line_obj = request.env['survey.user_input_line']
        try:
            user_input_id = user_input_obj.sudo().search([('token', '=', post['token'])])[0]
        except KeyError:  # Invalid token
            return request.website.render("website.403")
        for question in questions:
            answer_tag = "%s_%s_%s" % (survey.id, page_id, question.id)
            user_input_line_obj.save_lines(user_input_id, question, post, answer_tag)


        user_input = request.env['survey.user_input'].search([])
        go_back = post['button_submit'] == 'previous'
        next_page, _, last = survey_obj.next_page(user_input, page_id, go_back=go_back)
        vals = 'last_displayed_page_id': page_id
        if next_page is None and not go_back:
            vals.update('state': 'done')
        else:
            vals.update('state': 'skip')
        user_input_obj.write(user_input_id, vals)
        ret['redirect'] = '/survey/fill/%s/%s' % (survey.id, post['token'])
        if go_back:
            ret['redirect'] += '/prev'
    return json.dumps(ret)

【问题讨论】:

你能发布回溯的最后几行吗? 【参考方案1】:

在将任何模块从旧 API 迁移到新 API 时,可能会发生这种情况。您应该尝试this 文档。希望对你有帮助

【讨论】:

以上是关于RuntimeError:在运行 openerp 时调用 Python 对象时超出了最大递归深度的主要内容,如果未能解决你的问题,请参考以下文章

你如何运行 OpenERP yaml 单元测试

使用xml-rpc调试openerp模块中的函数

asyncio: RuntimeError 这个事件循环已经在运行

如何在 OpenERP 6 中安装 product_images_olbs 模块?

如何将BeautifulSoup导入到python方法OpenERP 7模块中

Python Asyncio - RuntimeError:无法关闭正在运行的事件循环