[FIX] website: allow retrying if website configurator fails

Whenever an error happens during the website creation after the last
step of the website configurator, it is displayed as an notification
popup, but it keeps the UI blocked, preventing the user from retrying
the operation.
The usually observed error is about not being able to install the module
or theme because a cron is in progress. The message actually asks the
user to retry later.

This commit does the following upon errors happening during the website
creation:
- silently retry after 5 seconds, up to 3 times
- after all attempts failed, display the error and release the UI and
allow for manual retry.

task-2809434

closes odoo/odoo#98124

X-original-commit: 2afdbc7181de3c87c1021f1e06d059ffe059ede0
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
This commit is contained in:
Benoit Socias
2022-08-16 15:06:52 +02:00
parent dcda0b8b56
commit 98e00bdb58
@@ -1,5 +1,6 @@
/** @odoo-module **/
import concurrency from 'web.concurrency';
import utils from 'web.utils';
import weUtils from 'web_editor.utils';
import {ColorpickerWidget} from 'web.Colorpicker';
@@ -356,6 +357,23 @@ class ApplyConfiguratorScreen extends Component {
if (!this.state.selectedPalette) {
return this.props.navigate(ROUTES.paletteSelectionScreen);
}
const attemptConfiguratorApply = async (data, retryCount = 0) => {
try {
return await this.orm.silent.call('website',
'configurator_apply', [], data
);
} catch (error) {
// Wait a bit before retrying or allowing manual retry.
await concurrency.delay(5000);
if (retryCount < 3) {
return attemptConfiguratorApply(data, retryCount + 1);
}
document.querySelector('.o_website_loader_container').remove();
throw error;
}
};
if (themeName !== undefined) {
this.websiteService.showLoader({ showTips: true });
const selectedFeatures = Object.values(this.state.features).filter((feature) => feature.selected).map((feature) => feature.id);
@@ -370,20 +388,18 @@ class ApplyConfiguratorScreen extends Component {
];
}
const resp = await this.orm.silent.call('website',
'configurator_apply',
[],
{
'selected_features': selectedFeatures,
'industry_id': this.state.selectedIndustry.id,
'selected_palette': selectedPalette,
'theme_name': themeName,
'website_purpose': WEBSITE_PURPOSES[
this.state.selectedPurpose || this.state.formerSelectedPurpose
].name,
'website_type': WEBSITE_TYPES[this.state.selectedType].name,
'logo_attachment_id': this.state.logoAttachmentId,
});
const data = {
'selected_features': selectedFeatures,
'industry_id': this.state.selectedIndustry.id,
'selected_palette': selectedPalette,
'theme_name': themeName,
'website_purpose': WEBSITE_PURPOSES[
this.state.selectedPurpose || this.state.formerSelectedPurpose
].name,
'website_type': WEBSITE_TYPES[this.state.selectedType].name,
'logo_attachment_id': this.state.logoAttachmentId,
};
const resp = await attemptConfiguratorApply(data);
this.props.clearStorage();