diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-02-11 17:00:35 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-02-11 17:00:35 +0100 |
| commit | 8c29df10e02e6777840ffd7a318472de29f77dd1 (patch) | |
| tree | 49c08eeab2620aa7e91e87256754763400c93376 /addons/website/static/src/js/widgets/ace.js | |
| parent | 0e71f91fa1ea8df0111d034069dcb92e27c5f0a3 (diff) | |
| parent | 93d736e905e0d3b110c36ee93af341021eba42c4 (diff) | |
[MERGE] forward port branch saas-12.1 up to 93d736e905e
Diffstat (limited to 'addons/website/static/src/js/widgets/ace.js')
| -rw-r--r-- | addons/website/static/src/js/widgets/ace.js | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/addons/website/static/src/js/widgets/ace.js b/addons/website/static/src/js/widgets/ace.js index 15df55e0c71..d9440be7b64 100644 --- a/addons/website/static/src/js/widgets/ace.js +++ b/addons/website/static/src/js/widgets/ace.js @@ -39,28 +39,29 @@ var WebsiteAceEditor = AceEditor.extend({ return this._super.apply(this, arguments).then((function () { var defs = []; if (this.currentType === 'xml') { + // When saving a view, the view ID might change. Thus, the + // active ID in the URL will be incorrect. After the save + // reload, that URL ID won't be found and JS will crash. + // We need to find the new ID (either because the view became + // specific or because its parent was edited too and the view + // got copy/unlink). var selectedView = _.findWhere(this.views, {id: this._getSelectedResource()}); - if (!selectedView.website_id[0]) { - // When saving a generic view, the view will be COW'd and - // replace by the specific view after the reload. Thus the id in - // URL won't exist anymore. We need to find the specific ID. - var context; - this.trigger_up('context_get', { - callback: function (ctx) { - context = ctx; - }, - }); - defs.push(this._rpc({ - model: 'ir.ui.view', - method: 'search_read', - fields: ['id'], - domain: [['key', '=', selectedView.key], ['website_id', '=', context.website_id]], - }).then((function (view) { - if (view[0]) { - this._updateHash(view[0].id); - } - }).bind(this))); - } + var context; + this.trigger_up('context_get', { + callback: function (ctx) { + context = ctx; + }, + }); + defs.push(this._rpc({ + model: 'ir.ui.view', + method: 'search_read', + fields: ['id'], + domain: [['key', '=', selectedView.key], ['website_id', '=', context.website_id]], + }).then((function (view) { + if (view[0]) { + this._updateHash(view[0].id); + } + }).bind(this))); } return $.when.apply($, defs).then((function () { window.location.reload(); |
