From b742e93bb05a71a34f5a2a4bd7835a318fc6603c Mon Sep 17 00:00:00 2001 From: "Louis (loco)" Date: Fri, 23 Jun 2023 11:23:31 +0200 Subject: [PATCH] [FIX] web_editor: do not create variant image while selecting an image Steps to reproduce the bug: - Go on a product page of a product with multiple variants but no image set for those variants. Because there is no image set to those variants, the variant images fall back on the template image. - Edit. - Click on the variant image of the product. (Note that `.o_dirty` is added to the element). - Save. -> The image of the product is not the template image anymore but a variant image that is the same as the template image. Because `.o_dirty` is added while clicking on the product image, `save_embedded_field()` will set the `image_1920` field of `product.product`. Because the product has multiple variants, the `image_variant_1920` field of `product.product` is modified see (`_set_template_field()`). The problem is that the `o_dirty` class is added on the clicked element. To solve the problem, the `MutationObserver` responsible for adding this class is paused when modifying the tooltips. Note that it was introduced by [1] but it was broken since [2]. [1]: https://github.com/odoo/odoo/commit/9f93fa8e77b11da2fcf60f606784eec49a94778a [2]: https://github.com/odoo/odoo/commit/8eb0ca54200f0f8e1078bb6a0d507e747ccea122 task-3111601 X-original-commit: 3b8f601f95845d65a515e9c8bb8e25cc17565dbf Part-of: odoo/odoo#133546 --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index ae413bc1872..ab7c6d0e51f 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -2179,13 +2179,13 @@ export class Wysiwyg extends Component { if (!this.showTooltip || $target.attr('title') !== undefined) { return; } - this.odooEditor.observerUnactive(); // Tooltips need to be cleared before leaving the editor. this.saving_mutex.exec(() => { + this.odooEditor.observerUnactive(); $target.tooltip({title: _t('Double-click to edit'), trigger: 'manual', container: 'body'}).tooltip('show'); + this.odooEditor.observerActive(); this.tooltipTimeouts.push(setTimeout(() => $target.tooltip('dispose'), 800)); }); - this.odooEditor.observerActive(); }, 400)); } // Hide button groups that have no visible buttons.