From 1f594ea744463a92b942c20733e9c9012ffbe6f9 Mon Sep 17 00:00:00 2001 From: Julien Banken Date: Mon, 13 Nov 2023 14:33:44 +0100 Subject: [PATCH] [FIX] web_editor: avoid conflict dialog when no versioning When the user creates a new article in Knowledge using a template, the system shows a dialog indicating that there is a conflict between the client and the server. This commit will ensure that the conflict dialog won't show up when the document does not have any versioning yet. Steps to reproduce the issue: 1. Go on Knowledge 2. Open the editor 3. Click on the "Browse Template" button 4. Choose a template 5. Click on the "Load Template" button Justification --- When the editor is started, the system generates a new snapshot with ids generated randomly (see: constructor of `OdooEditor`, `historyReset`, `_historyGetSnapshotStep`). When checking if the document is "stale" (i.e: out of sync), the system verifies the existence of a history step with the id specified in the `data-last-history-steps` attribute of the first node of the document (see: `_isLastDocumentStale`). If such a history step does not exist, the client document is considered "stale" and will be discarded. The `data-last-history-steps` attribute is set by the last writer when saving the document. When creating an article from a template, the server generates a new record and copies the template's body in the article's body. The system does not set any `data-last-history-steps` in the document. As a result, the document will be considered "stale" when opening the article and a conflict dialog will warn the user that the current document will be discarded. This commit will update the `_isLastDocumentStale` function to ensure that a document that has not been versioned yet won't be considered as "stale". The `data-last-history-steps` attribute will then be set when the user opens the article and save it. task-3587990 closes odoo/odoo#143194 X-original-commit: 69e7694580ae20bb21de1316de5aa770e7ed8eed Signed-off-by: Nicolas Bayet (nby) Signed-off-by: Julien Banken (jbn) --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 716f7db3087..5048df1bf0e 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -3007,6 +3007,9 @@ export class Wysiwyg extends Component { return record; } _isLastDocumentStale() { + if (!this._serverLastStepId) { + return false; + } return !this.odooEditor.historyGetBranchIds().includes(this._serverLastStepId); } /**