From e515650d16968971aa7098ca89e0d89249d829ab Mon Sep 17 00:00:00 2001
From: Nils Coenen <74965194+NICO-SOLUTIONS@users.noreply.github.com>
Date: Tue, 23 May 2023 23:17:44 +0200
Subject: [PATCH] [MIG] website_cookiebot: Migration to 16.0
---
website_cookiebot/__manifest__.py | 2 +-
website_cookiebot/readme/CONTRIBUTORS.rst | 3 +++
website_cookiebot/tests/__init__.py | 3 +++
.../tests/test_res_config_settings.py | 24 +++++++++++++++++++
.../wizards/res_config_settings.py | 2 +-
.../wizards/res_config_settings_views.xml | 5 +---
6 files changed, 33 insertions(+), 6 deletions(-)
create mode 100644 website_cookiebot/tests/__init__.py
create mode 100644 website_cookiebot/tests/test_res_config_settings.py
diff --git a/website_cookiebot/__manifest__.py b/website_cookiebot/__manifest__.py
index bb7f1ef580..a14c7a2474 100644
--- a/website_cookiebot/__manifest__.py
+++ b/website_cookiebot/__manifest__.py
@@ -5,7 +5,7 @@
"name": "Website Cookiebot",
"summary": "Ask for cookies consent connecting with Cookiebot",
"category": "Website",
- "version": "15.0.1.0.0",
+ "version": "16.0.1.0.0",
"author": "Trey (www.trey.es), Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/website",
"license": "AGPL-3",
diff --git a/website_cookiebot/readme/CONTRIBUTORS.rst b/website_cookiebot/readme/CONTRIBUTORS.rst
index 30435f2fa6..f4a564b9a0 100644
--- a/website_cookiebot/readme/CONTRIBUTORS.rst
+++ b/website_cookiebot/readme/CONTRIBUTORS.rst
@@ -5,3 +5,6 @@
* `Tecnativa `__:
* Jairo Llopis
* Stefan Ungureanu
+
+* `NICO SOLUTIONS - ENGINEERING & IT `__:
+ * Nils Coenen
diff --git a/website_cookiebot/tests/__init__.py b/website_cookiebot/tests/__init__.py
new file mode 100644
index 0000000000..ded7214fa9
--- /dev/null
+++ b/website_cookiebot/tests/__init__.py
@@ -0,0 +1,3 @@
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from . import test_res_config_settings
diff --git a/website_cookiebot/tests/test_res_config_settings.py b/website_cookiebot/tests/test_res_config_settings.py
new file mode 100644
index 0000000000..7ac6a1f3b6
--- /dev/null
+++ b/website_cookiebot/tests/test_res_config_settings.py
@@ -0,0 +1,24 @@
+# Copyright 2021 NICO SOLUTIONS - ENGINEERING & IT, Nils Coenen
+# License APL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo.tests.common import TransactionCase
+
+
+class TestResConfigSettings(TransactionCase):
+ def setUp(self):
+ super(TestResConfigSettings, self).setUp()
+ self.website = self.env["website"].create(
+ {"name": "Test Website", "cookiebot_dgid": "test_dgid"}
+ )
+ self.res_config_settings = self.env["res.config.settings"].create(
+ {"website_id": self.website.id}
+ )
+
+ def test_compute_cookiebot_enabled(self):
+ self.res_config_settings._compute_cookiebot_enabled()
+ self.assertTrue(self.res_config_settings.cookiebot_enabled)
+
+ def test_compute_cookiebot_enabled_no_dgid(self):
+ self.website.cookiebot_dgid = False
+ self.res_config_settings._compute_cookiebot_enabled()
+ self.assertFalse(self.res_config_settings.cookiebot_enabled)
diff --git a/website_cookiebot/wizards/res_config_settings.py b/website_cookiebot/wizards/res_config_settings.py
index a30c374d73..57ce03fc91 100644
--- a/website_cookiebot/wizards/res_config_settings.py
+++ b/website_cookiebot/wizards/res_config_settings.py
@@ -22,4 +22,4 @@ class ResConfigSettings(models.TransientModel):
@api.depends("website_id.cookiebot_dgid")
def _compute_cookiebot_enabled(self):
for record in self:
- record.cookiebot_enabled = bool(record.cookiebot_dgid)
+ record.update({"cookiebot_enabled": bool(record.cookiebot_dgid)})
diff --git a/website_cookiebot/wizards/res_config_settings_views.xml b/website_cookiebot/wizards/res_config_settings_views.xml
index 52c579b7f4..36f09d9c5c 100644
--- a/website_cookiebot/wizards/res_config_settings_views.xml
+++ b/website_cookiebot/wizards/res_config_settings_views.xml
@@ -6,10 +6,7 @@
res.config.settings
-
+