Files
odoo_source/addons/google_recaptcha/__manifest__.py
T
Guillaume (gdi)andqsm-odoo 852dba994e [FIX] google_recaptcha: fix traceback on show recaptcha policy
Steps to reproduce:
- Set up a recaptcha on a DB
- Drop a form block on a website page
- Click on the submit button
- Toggle the Show ReCaptcha option

=> A traceback is displayed. The bug is quite obvious: we try to render
a XML template which has not been loaded.

A bit of history:

Before [1], the "google_recaptcha" app was a dependency of the
"website_form" and "website_mass_mailing" apps only. Both needed to
render this recaptcha XML inside a snippet option JS file. That XML
definition was lazy loaded by the related JS widget: it made sense for
the XML definition to be defined in the "google_recaptcha" app, as an
util to be lazy loaded.

After [1] and before [2], the "website_form" app was merged in the
"website" app directly. The "google_recaptcha" app thus became a
dependency of the "website" app directly. The same XML was still lazy
loaded by "website" and by "website_mass_mailing". Since the "website"
app is a dependency of the "website_mass_mailing" app, it could have
made sense already to move the XML definition from "google_recaptcha" to
"website". Although as it was still lazy loaded, it still made sense to
keep it as a "google_recaptcha" util.

After [2], however, the XML lazy loading was entirely removed. That
change is debatable (and being debated again for future versions). But
meanwhile, the XML definition still in "google_recaptcha" was put inside
the "web.assets_frontend" bundle. This is wrong at multiple levels:

- Website visitors never need that XML definition, it should never have
  been added in there. We'll keep it however to respect stable policy.

- Since [3] (which occurred before [2]), the website editor UI is now in
  the backend. Having the recaptcha template XML definition defined in
  "web.assets_frontend" makes it inaccessible to editor options.

A fix could be to add the recaptcha XML definition in the
"website.assets_wysiwyg" bundle in the "website" manifest (as both JS
files which need that XML definition are defined in that bundle in
"website" and "website_mass_mailing"). It could be not really robust
though: if another custom app adds "google_recaptcha" as dependency and
put the XML definition in a different assets bundle, there could be
potential problems of having the same XML loaded twice (while the lazy
loading of before was smart enough to not load the same XML file twice).

As a fix, we put the definition in "web.assets_backend" directly. In
master, we may want to consider to reintroduce XML lazy loading and/or
move that XML file in "website" instead of "google_recaptcha".

[1]: https://github.com/odoo/odoo/commit/f8882698e8f4d1a3ad081522778344e2bd7aa0de
[2]: https://github.com/odoo/odoo/commit/39ea7a1fab257ab46a8faf97eea75cc37f8c43e5
[3]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

opw-3076185
opw-3096657

closes odoo/odoo#108005

X-original-commit: e76599d4b52f8c6a797907aeade5060dacd2987a
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
2022-12-15 12:37:09 +01:00

29 lines
938 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Google reCAPTCHA integration',
'category': 'Hidden',
'version': '1.0',
'description': """
This module implements reCaptchaV3 so that you can prevent bot spam on your public modules.
""",
'depends': ['base_setup'],
'data': [
'views/res_config_settings_view.xml',
],
'assets': {
'web.assets_frontend': [
'google_recaptcha/static/src/scss/recaptcha.scss',
'google_recaptcha/static/src/js/recaptcha.js',
],
'web.assets_backend': [
# TODO we may want to consider moving that file in website instead
# of here and/or adding it in the "website.assets_wysiwyg" bundle,
# which is lazy loaded.
'google_recaptcha/static/src/xml/recaptcha.xml',
],
},
'license': 'LGPL-3',
}