summaryrefslogtreecommitdiff
path: root/addons/web_editor/models
diff options
context:
space:
mode:
authorRomain Derie <rde@odoo.com>2018-12-07 10:38:37 +0000
committerRomain Derie <rde@odoo.com>2018-12-19 18:23:36 +0000
commitf7df35540b8404a14e8d29af80b8e8642a4c1bdb (patch)
tree3863f5d566a5dbdcf01b742cf45b20242d52e1d9 /addons/web_editor/models
parenteb19016ba35d4dc4723edcc244fd412680b5ff2f (diff)
[FIX] web_editor, website(_theme_install): avoid theme.ir.ui.view crash
In a particular case, `_views_get` was mixing apples and oranges, ir.ui.view and theme.ir.ui.view. This was the case if a theme has a theme.ir.ui.view t-calling another theme.ir.ui.view. (Only theme's sale bridge cause this issue, eg theme_kea_sale.products) Then, having that theme installed on a website would make all other website without that theme to crash when opening the /shop customize menu. Indeed, the theme.ir.ui.view would have the xml_id theme_kea_sale.search. The generic view `website_sale.products` would have `theme_kea_sale.products` as inherit child which is website specific and t-call `theme_kea_sale.search`. Then, on a website witout theme_kea installed, opening the customize menu would call `get_related_views` that would call `_views_get` that would loop through inherit children calling `_view_obj` that would not find a view with that key and would fallback on self.env.ref, finding the theme.ir.ui.view. Note: `_views_get` might return specific view for another website but that will be filtered on `get_related_views` override in website. Step to reproduce: - Have at least 2 websites and website_sale installed - Install theme_kea on a website, it will also install theme_kea_sale - Go on the website that has not theme_kea installed - Go to /shop - Open Customize menu, it won't load because of python crash opw-1914576 Closes #29347
Diffstat (limited to 'addons/web_editor/models')
-rw-r--r--addons/web_editor/models/ir_ui_view.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/addons/web_editor/models/ir_ui_view.py b/addons/web_editor/models/ir_ui_view.py
index 45211502f11..908f58e6b8c 100644
--- a/addons/web_editor/models/ir_ui_view.py
+++ b/addons/web_editor/models/ir_ui_view.py
@@ -205,7 +205,8 @@ class IrUiView(models.Model):
return self.search([('key', '=', view_id)], limit=1) or self.env.ref(view_id)
elif isinstance(view_id, pycompat.integer_types):
return self.browse(view_id)
- # assume it's already a view object (WTF?)
+ # It can already be a view object when called by '_views_get()' that is calling '_view_obj'
+ # for it's inherit_children_ids, passing them directly as object record.
return view_id
# Returns all views (called and inherited) related to a view
@@ -224,7 +225,7 @@ class IrUiView(models.Model):
view = self._view_obj(view_id)
except ValueError:
_logger.warning("Could not find view object with view_id '%s'", view_id)
- return []
+ return self.env['ir.ui.view']
while root and view.inherit_id:
view = view.inherit_id
@@ -240,7 +241,7 @@ class IrUiView(models.Model):
called_view = self._view_obj(child.get('t-call', child.get('t-call-assets')))
except ValueError:
continue
- if called_view not in views_to_return:
+ if called_view and called_view not in views_to_return:
views_to_return += self._views_get(called_view, options=options, bundles=bundles)
extensions = view.inherit_children_ids