[FIX] website_form: fix norecaptcha behavior

Adapt [1] to be a bit more robust.

[1]: https://github.com/odoo/odoo/commit/eb9373522628fa01c3503fa802ded23adc1cbe1f

closes odoo/odoo#66508

X-original-commit: 028ae76f3b53132ae5c1510a4285cc21fc120c76
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2021-02-18 20:29:14 +00:00
parent d10d0b2da4
commit 4b2f5975fa
@@ -28,6 +28,7 @@ odoo.define('website_form.s_website_form', function (require) {
willStart: function () {
const res = this._super(...arguments);
if (!this.$target[0].classList.contains('s_website_form_no_recaptcha')) {
this._recaptchaLoaded = true;
this._recaptcha.loadLibs();
}
return res;
@@ -155,7 +156,7 @@ odoo.define('website_form.s_website_form', function (require) {
form_values[$(this).find('input').attr('name')] = date.format(format);
});
if (!this.$target[0].classList.contains('s_website_form_no_recaptcha')) {
if (this._recaptchaLoaded) {
const tokenObj = await this._recaptcha.getToken('website_form');
if (tokenObj.token) {
form_values['recaptcha_token_response'] = tokenObj.token;