Skip to content

Commit

Permalink
Merge PR #1055 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Aug 14, 2024
2 parents 9369732 + 6faa540 commit 6ec46a3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
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

0 comments on commit 6ec46a3

Please sign in to comment.