diff options
| author | qsm-odoo <qsm@odoo.com> | 2019-02-05 11:17:36 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2019-02-06 09:49:11 +0000 |
| commit | 930839c76bd78fb983f1ea819c49ad20d65cff07 (patch) | |
| tree | b4077819d2d024bc10f47004dfe78cbadec01420 /addons/website/static/src/js/menu/edit.js | |
| parent | aef6a5aaed22b250799ce92b5021d240fed9e12e (diff) | |
[FIX] website: remove data-editor-message attributes on save
When the edit mode is entered, some elements receive
data-editor-message attributes. These were not removed on save which
could in some cases make the attributes be saved in the database. For
this to happen it would require an `.oe_structure.oe_empty` element to
be put *inside* an editable element (instead of being the one which is
editable). In that case the `.oe_structure` content would be saved in an
inheriting view but the parent view would also be COW'd for no reason
because of that attribute.
Difficult to say if such a case exist in the current views but as it
technically possible and that some of our tests use that configuration,
it is worth fixing.
Note: this fix was in fact done in the new editor in master and allowed
to detect that one of our test was not testing a feature correctly
because of that. This will be adapted in a different commit of this PR.
closes odoo/odoo#30834
Diffstat (limited to 'addons/website/static/src/js/menu/edit.js')
| -rw-r--r-- | addons/website/static/src/js/menu/edit.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/addons/website/static/src/js/menu/edit.js b/addons/website/static/src/js/menu/edit.js index d02f96568db..a3015a78a6a 100644 --- a/addons/website/static/src/js/menu/edit.js +++ b/addons/website/static/src/js/menu/edit.js @@ -83,7 +83,8 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ self.$welcomeMessage.remove(); } var $wrapwrap = $('#wrapwrap'); // TODO find this element another way - $wrapwrap.find('.oe_structure.oe_empty, [data-oe-type="html"]').attr('data-editor-message', _t('DRAG BUILDING BLOCKS HERE')); + self.$editorMessageElements = $wrapwrap.find('.oe_structure.oe_empty, [data-oe-type="html"]') + .attr('data-editor-message', _t('DRAG BUILDING BLOCKS HERE')); var def = $.Deferred(); self.trigger_up('animation_start_demand', { editableMode: true, @@ -102,10 +103,19 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ * expects that the save action is performed. So, this empty action is * defined here so that all users have an 'on_save' related action. * + * As explained above, that action should always be defined in the current + * implementation (even an empty one) but in fact it is also needed to + * remove the data-editor-message attributes which are added when entering + * edition. + * * @private * @todo improve the system to somehow declare required/optional actions */ - _onSave: function () {}, + _onSave: function () { + if (this.$editorMessageElements) { + this.$editorMessageElements.removeAttr('data-editor-message'); + } + }, //-------------------------------------------------------------------------- // Handlers |
