[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
This commit is contained in:
Aaron Bohy
2022-09-17 00:51:29 +02:00
parent b658171ea2
commit f6bc1af630
@@ -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);
}
};
}