From f6bc1af630773ae74bf2a27c1cd9a3bcdce2d478 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 16 Sep 2022 09:11:21 +0000 Subject: [PATCH] [FIX] web: RelationalModel: wait for load before rendering This commit fixes a race condition in the RelationalModel, which can be identified by a ListView test [1], with a subset of addons installed. Before the fix, we didn't wait for the record to be reloaded before re-rendering the list. It could then crash because the data object was empty (not yet filled with values). This commit also prevent unnecessary reload/rerendering after an urgent save, i.e. when the user is closing the tab. [1] editing a record should change same record in other groups when grouped by m2m field Part-of: odoo/odoo#100356 --- addons/web/static/src/views/relational_model.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/views/relational_model.js b/addons/web/static/src/views/relational_model.js index 5373cef3d91..8c5ff3b3e0d 100644 --- a/addons/web/static/src/views/relational_model.js +++ b/addons/web/static/src/views/relational_model.js @@ -555,7 +555,7 @@ export class Record extends DataPoint { async urgentSave() { this._urgentSave = true; this.model.env.bus.trigger("RELATIONAL_MODEL:WILL_SAVE_URGENTLY"); - this._save(); + this._save({ stayInEdition: true, noReload: true }); } async archive() { @@ -1414,7 +1414,7 @@ class DynamicList extends DataPoint { this.editedRecord = record; } if (params.onRecordWillSwitchMode) { - params.onRecordWillSwitchMode(record, mode); + await params.onRecordWillSwitchMode(record, mode); } }; }