[FIX] base,web_editor: get_view_id should return singleton

Because of 9a98a4d60e
and since the key of an ir.ui.view cannot be unique
(multiwebsite), duplicating views made several parts of Odoo crash

After this commit, we limit to one the views that are searched with their key
Responsibility is given to the user to change the priority and/or the key
in order to predict which view will be taken

OPW 1913335,1913100,1913186,1913112,1913240

closes odoo/odoo#29105
This commit is contained in:
Lucas Perais (lpe)
2018-11-28 15:26:48 +00:00
parent 293dbe267a
commit c432667fbf
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -202,7 +202,7 @@ class IrUiView(models.Model):
@api.model
def _view_obj(self, view_id):
if isinstance(view_id, pycompat.string_types):
return self.search([('key', '=', view_id)]) or self.env.ref(view_id)
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?)
+1 -1
View File
@@ -1179,7 +1179,7 @@ actual arch.
return template
if '.' not in template:
raise ValueError('Invalid template id: %r' % template)
view = self.search([('key', '=', template)])
view = self.search([('key', '=', template)], limit=1)
return view and view.id or self.env['ir.model.data'].xmlid_to_res_id(template, raise_if_not_found=True)
def clear_cache(self):