[FIX] web: fix test failing on split builds

Before this commit, test "click on the progressBar of a new column"
deterministically failed on split builds. It only passed with all
addons installed, and passed by chance with all addons installed.

The reason is that the flow of quick creating a record in a grouped
kanban with progressbars wasn't concurrency proof at all. Commit [1]
simply added a hook at the end of the `_save` function of the model,
which highlighted the problem: the progressbars were updated before
the group's count was incremented, so if the quick created record
was the only record of the group, the progressbar was still empty
after the quick creation.

This commit makes the quick create code more robust.

We couldn't find a way to write a qunit test for this, but it still
fixes an error in nightly builds.

[1] a882b725bb

closes odoo/odoo#109818

X-original-commit: cbfad9c36f4e52309903702f21cea457acc55ecb
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Aaron Bohy
2023-01-13 09:18:53 +01:00
parent 0085074373
commit 5d060079f0
2 changed files with 18 additions and 13 deletions
@@ -283,16 +283,24 @@ class KanbanGroup extends Group {
*/
async validateQuickCreate() {
const record = this.list.quickCreateRecord;
let saved = false;
if (record) {
const saved = await record.save();
if (saved) {
this.addRecord(this.removeRecord(record), 0);
this.count++;
this.list.count++;
return record;
}
saved = await this.model.mutex.exec(async () => {
const saved = await record._save({ noReload: true, stayInEdition: true });
if (saved) {
this.count++;
if (record.parentActiveFields) {
record.setActiveFields(record.parentActiveFields);
record.parentActiveFields = false;
}
await this.model.reloadRecords(record);
record.switchMode("readonly");
this.addRecord(this.removeRecord(record), 0);
}
return saved;
});
}
return false;
return saved ? record : false;
}
// ------------------------------------------------------------------------
@@ -1412,6 +1412,7 @@ export class Record extends DataPoint {
delete this.virtualId;
this.data.id = this.resId;
this.resIds.push(this.resId);
this._changes = {};
this.invalidateCache();
} else if (keys.length > 0) {
try {
@@ -1422,14 +1423,10 @@ export class Record extends DataPoint {
}
throw e;
}
this._changes = {};
this.invalidateCache();
}
// Switch to the parent active fields
if (this.parentActiveFields) {
this.setActiveFields(this.parentActiveFields);
this.parentActiveFields = false;
}
this.isInQuickCreation = false;
if (shouldReload) {
await this.model.reloadRecords(this);