From 0c7c50b9382812fee85d2fe58b606c7cb3a9f0d7 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Mon, 16 Feb 2015 09:56:40 +0100 Subject: [PATCH] [FIX] website: allow to edit a page created by cms. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this fix, you cannot use html_editor to edit page create with the front end. Since we don't store the new page in field `xml_id´ but in field `key´, we need to search also into this field. --- addons/website/models/ir_ui_view.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 71ee6d22e3b..7af59d57091 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -35,9 +35,18 @@ class view(osv.osv): def _view_obj(self, cr, uid, view_id, context=None): if isinstance(view_id, basestring): - return self.pool['ir.model.data'].xmlid_to_object( - cr, uid, view_id, raise_if_not_found=True, context=context - ) + try: + return self.pool['ir.model.data'].xmlid_to_object( + cr, uid, view_id, raise_if_not_found=True, context=context + ) + except: + # Try to fallback on key instead of xml_id + rec_id = self.search(cr, uid, [('key', '=', view_id)], context=context) + if rec_id: + _logger.info("Could not find view with `xml_id´ '%s', fallback on `key´" % (view_id)) + return self.browse(cr, uid, rec_id, context=context)[0] + else: + raise elif isinstance(view_id, (int, long)): return self.browse(cr, uid, view_id, context=context)