Skip to content

Commit

Permalink
[FIX] website_cookiebot: disable for sure
Browse files Browse the repository at this point in the history
If we don't remove the key the assets will keep trying to load, which
isn't what we'd expect.

TT50520
  • Loading branch information
chienandalu authored and Anxo82 committed Aug 21, 2024
1 parent 4fb96f7 commit dbd273a
Show file tree
Hide file tree
Showing 5 changed files with 9 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": "17.0.1.0.0",
"version": "17.0.1.0.1",
"author": "Trey (www.trey.es), Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/website",
"license": "AGPL-3",
Expand Down
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 dbd273a

Please sign in to comment.