The _view_get function is a recursive function used to retieve all the views related to a view (inherited or t-called). The issue is that by an odd set of circumstances it is possible to have a loop in the view graph. Resulting in the recursive function being called until a "maximum recursion depth exceeded" error occurs. Example of a loop: A t-call B and A inherit from B This is possible on an update of a view that has been forked by website: If the view A was doing a t-call on B and is has been duplicated with the arch modified. When we update with the changes A now inherit from B instead of t-call B Since the arch was modified it will not be updated so A will still t-call B but the inherit_id of A is unchanged so it will be updated to reference B resulting in a loop. closes odoo/odoo#51620 X-original-commit: 63e1e84ebd7e609d6e06d83dc0f0092688b013eb Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
28 lines
952 B
Python
28 lines
952 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo.tests import TransactionCase
|
|
|
|
|
|
class TestViews(TransactionCase):
|
|
def test_infinite_inherit_loop(self):
|
|
# Creates an infinite loop: A t-call B and A inherit from B
|
|
View = self.env['ir.ui.view']
|
|
first_view = View.create({
|
|
'name': 'Test View 1',
|
|
'type': 'qweb',
|
|
'arch': '<div>Hello World</div>',
|
|
'key': 'web_editor.test_first_view',
|
|
})
|
|
second_view = View.create({
|
|
'name': 'Test View 2',
|
|
'type': 'qweb',
|
|
'arch': '<t t-call="web_editor.test_first_view"/>',
|
|
'key': 'web_editor.test_second_view',
|
|
})
|
|
second_view.write({
|
|
'inherit_id': first_view.id,
|
|
})
|
|
# Test for RecursionError: maximum recursion depth exceeded in this function
|
|
View._views_get(first_view)
|