[FIX] Fix check_xml when inheriting from views created in the same module

When inheriting from a view in extension mode created in the same module, this
view was not loaded during check_xml of the last view.
This caused an error when the last view wants to modify elements added
by its direct parent view.

Example :
- View1, created in module "account"
- View2, mode extension, created in module "customer", inherits View1
- View3, created in module "customer", inherits View2

During update of module "customer", when loading View3, the check_xml
call didn't load View2, because it's defined in the same module (and,
obviously, this module has not be totally loaded at this point)

This is fixed by adding direct parent of each loaded view in the
check_view_ids list in context, to force them to be loaded.

Closes #9135
This commit is contained in:
Sylvain GARANCHER 2015-10-19 13:55:25 +02:00 committed by Denis Ledoux
parent a617fd29ae
commit 11cd22711c
1 changed files with 5 additions and 0 deletions

View File

@ -509,10 +509,15 @@ class view(osv.osv):
requested (similar to ``id``)
"""
if context is None: context = {}
context = context.copy()
# if view_id is not a root view, climb back to the top.
base = v = self.browse(cr, uid, view_id, context=context)
check_view_ids = context.setdefault('check_view_ids', [])
while v.mode != 'primary':
# Add inherited views to the list of loading forced views
# Otherwise, inherited views could not find elements created in their direct parents if that parent is defined in the same module
check_view_ids.append(v.id)
v = v.inherit_id
root_id = v.id