[FIX] website: properly check for option reload when page options

Follow-up of [1]. Commit [2] refactored the way we check if an option
update needs to trigger a page reload: if the option is marked as a
page option (`data-page-options="true"` on the option's main `<div>`),
then it will reload whatever the method used if there is a `reload`
parameter. Note that this `reload` parameter does not make much sense
anymore, it should be reviewed/removed in master.

Problem: [2] made a mistake in its implementation, pushing an array
instead of concatenating it. This worked by chance, as instead of asking
"does this option method requires a reload", it was asking "does this
set of option methods requires a reload"... and in that case, the code
is fallbacking on retrieving common parameters, which `reload` likely
is without custo. This could have been fixed in master only. Given the
very low risk of breaking anything critical updating this code, it was
chosen to prevent a potential crash in custo (which could occur as we
give a wrong parameter type to a main method) and allow overrides to
make `reload` a specific parameter for a specific method without the
need of `data-reload` added in the DOM.

[1]: https://github.com/odoo/odoo/commit/556ae457b02e9c077d09fa9c3f9f1e6c6e26b345
[2]: https://github.com/odoo/odoo/commit/03c552690b15cbf2e7d6b7812386ac64042219af#diff-70f7fe38208aa7fe678f18e329d3c11b70065dee723921352b6005774e8bab53R456

closes odoo/odoo#159927

X-original-commit: 337fbdc35ee0da2ae9d0a524a8b084c959949c78
Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2024-04-02 10:23:01 +00:00
parent d4674489f2
commit 58341739e7
@@ -727,28 +727,10 @@ options.Class.include({
}
for (const widget of widgets) {
const methodsNames = widget.getMethodsNames();
const specialMethodsNames = [];
// If it's a pageOption, it's most likely to need to reload, so check the widgets.
if (this.data.pageOptions) {
specialMethodsNames.push(methodsNames);
} else {
for (const methodName of methodsNames) {
if (this.specialCheckAndReloadMethodsNames.includes(methodName)) {
specialMethodsNames.push(methodName);
}
}
}
if (!specialMethodsNames.length) {
continue;
}
let paramsReload = false;
for (const methodName of specialMethodsNames) {
if (widget.getMethodsParams(methodName).reload) {
paramsReload = true;
break;
}
}
if (paramsReload) {
const methodNamesToCheck = this.data.pageOptions
? methodsNames
: methodsNames.filter(m => this.specialCheckAndReloadMethodsNames.includes(m));
if (methodNamesToCheck.some(m => widget.getMethodsParams(m).reload)) {
return true;
}
}