Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] website_cookiebot: disable for sure #1055

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website_cookiebot/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Website Cookiebot",
"summary": "Ask for cookies consent connecting with Cookiebot",
"category": "Website",
"version": "16.0.1.0.0",
"version": "16.0.2.0.0",
"author": "Trey (www.trey.es), Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/website",
"license": "AGPL-3",
Expand Down
10 changes: 10 additions & 0 deletions website_cookiebot/migrations/16.0.2.0.0/post-migrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2024 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
# We're adding cookiebot_enabled to the website so it's easier to disable the
# cookiebot scripts temporarily
env["website"].search([("cookiebot_dgid", "!=", False)]).cookiebot_enabled = True
1 change: 1 addition & 0 deletions website_cookiebot/models/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class Website(models.Model):
string="Cookiebot Domain Group ID",
help="Get this code from Cookiebot to enable it on the website.",
)
cookiebot_enabled = fields.Boolean()
6 changes: 4 additions & 2 deletions website_cookiebot/templates/assets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<!-- This should be the first script loaded;
see https://cookiebot.com/goto/help -->
<xpath expr="//head/script" position="before">
<t t-if="website.cookiebot_dgid and not editable">
<t
t-if="website.cookiebot_enabled and website.cookiebot_dgid and not editable"
>
<script
id="Cookiebot"
src="https://consent.cookiebot.com/uc.js"
Expand All @@ -21,7 +23,7 @@
<xpath expr="//script[@id='tracking_code']" position="attributes">
<attribute
name="t-att-type"
>website.cookiebot_dgid and 'text/plain'</attribute>
>website.cookiebot_enabled and website.cookiebot_dgid and 'text/plain'</attribute>
<attribute name="data-cookieconsent">statistics</attribute>
</xpath>
</template>
Expand Down
4 changes: 2 additions & 2 deletions website_cookiebot/templates/website.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
expr="//footer//div/span[hasclass('o_footer_copyright_name')]"
position="after"
>
<span t-if="website.cookiebot_dgid">- <a
<span t-if="website.cookiebot_enabled and website.cookiebot_dgid">- <a
href="/legal/cookies-policy"
>Cookies Policy</a></span>
</xpath>
Expand All @@ -21,7 +21,7 @@
</section>
</div>
<section
t-if="website.cookiebot_dgid and not editable"
t-if="website.cookiebot_enabled and website.cookiebot_dgid and not editable"
class="mb-5 mt-5"
>
<div class="container">
Expand Down
7 changes: 1 addition & 6 deletions website_cookiebot/wizards/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ class ResConfigSettings(models.TransientModel):
)
cookiebot_enabled = fields.Boolean(
string="Cookiebot",
compute="_compute_cookiebot_enabled",
related="website_id.cookiebot_enabled",
readonly=False,
)

@api.depends("website_id.cookiebot_dgid")
def _compute_cookiebot_enabled(self):
for record in self:
record.cookiebot_enabled = bool(record.cookiebot_dgid)

@api.onchange("website_cookies_bar")
def _onchange_website_cookies_bar(self):
for record in self:
Expand Down
Loading