From 44266e757e352488d0dcd57bf43bfcef6d4a9d8e Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Wed, 27 Sep 2023 15:25:11 +0200 Subject: [PATCH] [FIX] web_editor: generate client id when saving new record The issue #128847 broke the fix of #124802. Wysiwyg._generateClientId must be called before `Wysiwyg.resetValue` as `Wysiwyg.resetValue` will call `Wysiwyg.odooEditor.historyReset` which need to have the client id set to consider the collaboration active and serialize the node accordingly. task-3457120 closes odoo/odoo#138442 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 6 ++++-- 1 file changed, 4 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 41ae22388c3..4a684f5e8b8 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -356,6 +356,7 @@ export class Wysiwyg extends Component { let editorCollaborationOptions; if (this._isCollaborationEnabled(options)) { + this._currentClientId = this._generateClientId(); editorCollaborationOptions = this.setupCollaboration(options.collaborationChannel); if (this.options.collaborativeTrigger === 'start') { this._joinPeerToPeer(); @@ -692,7 +693,6 @@ export class Wysiwyg extends Component { this.busService.deleteChannel(this._collaborationChannelName); } - this._currentClientId = this._generateClientId(); this._startCollaborationTime = new Date().getTime(); this._checkConnectionChange = () => { @@ -3165,12 +3165,14 @@ export class Wysiwyg extends Component { this._rulesCache = undefined; // Reset the cache of rules. // If there is no collaborationResId, the record has been deleted. if (!this._isCollaborationEnabled(this.options)) { + this._currentClientId = undefined; this.resetValue(value); return; } + this._currentClientId = this._generateClientId(); + this.odooEditor.collaborationSetClientId(this._currentClientId); this.resetValue(value); this.setupCollaboration(collaborationChannel); - this.odooEditor.collaborationSetClientId(this._currentClientId); if (this.options.collaborativeTrigger === 'start') { this._joinPeerToPeer(); } else if (this.options.collaborativeTrigger === 'focus') {