[FIX] web: SearchPanel: fix race condition with sections

This commit fixes a race condition spotted by the click all test,
in the Lunch application. To reproduce, go to Lunch > Configuration
> Products, in the list view, toggle filter "Archived" s.t. there's
no record matching the domain (and nothing displayed in the search
panel anymore), then switch to kanban view, and remove the filter.
On a multi-build, this scenario fails ~4 times out of 10.

The issue occurs because a re-rendering of the search panel is
triggered by its parent (because of the filter change), but the
search panel didn't compute its active sections yet (this is done
when the "update" event is triggered on the search model). The
exact situation is hard to reproduce, but if there are non empty
sections in the model, and the active sections haven't been computed
yet in the search panel, it crashes. For instance, it happens all
the time by delaying the promise returned by "_fetchSections".

This commit doesn't introduce a qunit test because we didn't manage
to reproduce the exact same situation in a test. This makes the
Lunch click all test pass all the time though.

closes odoo/odoo#103638

X-original-commit: b84df7e08b4d413de2e8a0b1df6cb8d6ad4b08cf
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Aaron Bohy
2022-10-20 14:14:56 +02:00
parent 5c57230536
commit b7dfc7f71c
@@ -2,7 +2,7 @@
import { useBus } from "@web/core/utils/hooks";
const { Component, onMounted, onWillStart, useRef, useState } = owl;
const { Component, onMounted, onWillUpdateProps, onWillStart, useRef, useState } = owl;
//-------------------------------------------------------------------------
// Helpers
@@ -59,6 +59,11 @@ export class SearchPanel extends Component {
this.updateActiveValues();
});
onWillUpdateProps(async () => {
await this.env.searchModel.sectionsPromise;
this.updateActiveValues();
});
onMounted(() => {
this.updateGroupHeadersChecked();
if (this.hasImportedState) {