Skip to content

Commit

Permalink
[MIG] website_cookiebot: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adriresu committed Jun 20, 2024
1 parent 9f719a5 commit 20e946b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 44 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": "17.0.1.0.0",
"author": "Trey (www.trey.es), Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/website",
"license": "AGPL-3",
Expand Down
3 changes: 3 additions & 0 deletions website_cookiebot/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import test_website_cookiebot
22 changes: 22 additions & 0 deletions website_cookiebot/tests/test_website_cookiebot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# © 2024 Solvos Consultoría Informática (<http://www.solvos.es>)
# License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html

from odoo.tests.common import TransactionCase


class TestWebsiteCookiebot(TransactionCase):
def test_conf_cookiebot_domain(self):
domain_group_id = "9a9999a9-aa99-9a99-999a-aa999999999a"
config = self.env["res.config.settings"].sudo().create({})
config.write({"cookiebot_dgid": domain_group_id})
self.assertTrue(config.cookiebot_enabled)
self.assertFalse(config.website_cookies_bar)
self.assertEqual(config.cookiebot_dgid, domain_group_id)

def test_conf_website_cookies_bar(self):
config = self.env["res.config.settings"].sudo().create({})
config.write({"website_cookies_bar": True})
config._onchange_website_cookies_bar()
self.assertTrue(config.website_cookies_bar)
self.assertFalse(config.cookiebot_enabled)
self.assertFalse(config.cookiebot_dgid)
82 changes: 39 additions & 43 deletions website_cookiebot/wizards/res_config_settings_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,49 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="website.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='website_cookies_bar_setting']" position="after">
<div class="col-xs-12 col-md-6 o_setting_box" id="cookiebot_setting">
<div class="o_setting_left_pane">
<field name="cookiebot_enabled" />
<xpath expr="//setting[@id='website_cookies_bar_setting']" position="after">
<setting class="col-xs-12 col-md-6" id="cookiebot_setting">
<field name="cookiebot_enabled" />
<label for="cookiebot_enabled" />
<span
class="fa fa-lg fa-globe"
title="Values set here are website-specific."
groups="website.group_multi_website"
/>
<div class="text-muted">
Ask for consent on cookies usage
</div>
<div class="o_setting_right_pane">
<label for="cookiebot_enabled" />
<span
class="fa fa-lg fa-globe"
title="Values set here are website-specific."
groups="website.group_multi_website"
/>
<div class="text-muted">
Ask for consent on cookies usage
<div
class="content-group"
invisible="cookiebot_enabled == False"
id="cookiebot_fields"
>
<div class="mt16">
<a
href="https://cookiebot.com/goto/help"
class="oe_link"
target="_blank"
>
<i class="fa fa-arrow-right" />
How to configure Cookiebot.
</a>
<span class="text-muted">
Instead of step 3, paste here your Domain Group ID.
</span>
</div>
<div
class="content-group"
attrs="{'invisible': [('cookiebot_enabled', '=', False)]}"
id="cookiebot_fields"
>
<div class="mt16">
<a
href="https://cookiebot.com/goto/help"
class="oe_link"
target="_blank"
>
<i class="fa fa-arrow-right" />
How to configure Cookiebot.
</a>
<span class="text-muted">
Instead of step 3, paste here your Domain Group ID.
</span>
</div>
<div class="row mt16">
<label
class="col-md-3 o_light_label"
for="cookiebot_dgid"
/>
<field
name="cookiebot_dgid"
placeholder="00000000-0000-0000-0000-000000000000"
attrs="{'required': [('cookiebot_enabled', '=', True)]}"
/>
</div>
<div class="row mt16">
<label
class="col-md-3 o_light_label"
for="cookiebot_dgid"
/>
<field
name="cookiebot_dgid"
placeholder="00000000-0000-0000-0000-000000000000"
required="cookiebot_enabled == True"
/>
</div>
</div>
</div>
</setting>
</xpath>
</field>
</record>
Expand Down

0 comments on commit 20e946b

Please sign in to comment.