d1a867553da2c99f2895e1ea9ed29f5d6b295a1f
* website_event Commit https://github.com/odoo/odoo/commit/a153ed42a09f8b7f5e0865112eb7d5affc22a353 solved a big problem which was that when an undo/redo is performed, the whole DOM was reconstructed breaking all the JS relying on the old one. For example, the latest blog posts which are dynamically loaded in JS were not removed before saving since the JS relied on the old DOM... and this broke the page because that dynamic content contained non-valid XML markup. The solution was to destroy all JS widgets before applying an undo/redo and rebuilding them all afterwards. Ideally this operation should be done on the undo recording action but this would have a huge flickering impact since many DOM would be destroyed each time the user types text (flickering which is also bad on undo/redo but it is more acceptable). The problem now is the following: if a widget, like many, is declared like this: ``` start: function () { this.$el.append(/* Some dynamic content on page loading */); }, destroy: function () { this.$el.find(/* Dynamic content to remove */).remove(); }, ``` Then it works in all standard cases: dynamic content is loaded on page load and is removed when saving the editor. But this happens with the undo/redo system: 1. The users types text, we record an undo, which is the whole page current DOM, containing all the dynamic contents. 2. The users hits CTRL-Z: a. We destroy all JS widgets, calling destroy, the dynamic content is removed from the page. b. We replace the whole DOM with the one that was saved. That one contains the dynamic content DOM. c. The JS widgets are recreated, calling start... creating the dynamic content again. Result: the dynamic content appears duplicated. On save, depending on how the destroy was implemented only the last generated content may be removed or both... but in any case it appears duplicated during edition. Hopefully, our current stable version do not contain that many dynamic content so a perfect amelioration of all of this can be found in master. As a fix, this commit introduces an extra step between (a) and (b): we remove the dynamic content of the DOM-to-re-apply before applying it. For this to work, widgets have to mark their dynamic content with the class 'o_temp_auto_element' when creating it. They also must add the content they replace on the 'data-temp-auto-element-original-content' attribute. closes odoo/odoo#44025 X-original-commit: f0d2559afd3094f6fbd7e6788f7c10fa421c9080 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Odoo
Odoo is a suite of web based open source business apps.
The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...
Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.
Getting started with Odoo
For a standard installation please follow the Setup instructions from the documentation.
To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials
Languages
Python
49.6%
JavaScript
47.8%
SCSS
2%
CSS
0.3%
HTML
0.2%