From faeeea76e967bcb187b2c3fe7cab576b09366153 Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Tue, 13 Jun 2023 08:59:53 +0000 Subject: [PATCH] [FIX] web_editor: set the clientId after creating it Before this commit, when creating a new record, there is no `_currentClientId` set in the wysiwyg as there is no collaboration setup for new records. When the user save the record, there is a call to `Wysiwyg.resetEditor` but as the `OdooEditor.collaborationSetClientId` was called before `Wysiwyg.setupCollaboration`, the `_currentClientId` was not set. That lead to the `OdooEditor._collabClientId` being undefined, which lead `OdooEditor.serializeNode` to not serialize the node through the function `serializeNode`. So unless the client A reload it's page, if another client (B) open the same record and synchronize with client A, client A will send it's history when `get_history_from_snapshot` is triggered but no `_historySteps` mutations nodes will not be serialized. So when client B will receive the steps in `historyResetFromSteps`, the code will crash. After this commit, the proper order will set the _currentClientId in time because `collaborationSetClientId` is set after `setupCollaboration`. task-3359732 closes odoo/odoo#125599 X-original-commit: 85acd380cab34ca507251c8b232520c76f2a3e58 Signed-off-by: David Monjoie (dmo) --- 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 0ae769905e1..31d0e54cedc 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -2658,10 +2658,10 @@ const Wysiwyg = Widget.extend({ this.odooEditor.historyReset(); return; } - this.odooEditor.collaborationSetClientId(this._currentClientId); this.setValue(value); - this.odooEditor.historyReset(); this.setupCollaboration(collaborationChannel); + this.odooEditor.collaborationSetClientId(this._currentClientId); + this.odooEditor.historyReset(); if (this.options.collaborativeTrigger === 'start') { this._joinPeerToPeer(); } else if (this.options.collaborativeTrigger === 'focus') {