From 96e244055f222bc2e5bd08fa7ab36d58c2a5ee89 Mon Sep 17 00:00:00 2001 From: Tom Blauwendraat Date: Wed, 17 Aug 2022 19:46:10 +0200 Subject: [PATCH] fixup! [MIG] database_cleanup: Migration to 14.0 --- database_cleanup/models/purge_modules.py | 2 +- database_cleanup/models/purge_wizard.py | 4 ++-- database_cleanup/tests/common.py | 3 --- database_cleanup/tests/test_create_indexes.py | 4 ++++ database_cleanup/tests/test_purge_columns.py | 3 +++ database_cleanup/tests/test_purge_data.py | 4 ++++ database_cleanup/tests/test_purge_menus.py | 4 ++++ database_cleanup/tests/test_purge_models.py | 6 +++++- database_cleanup/tests/test_purge_modules.py | 20 ++++++------------- .../tests/test_purge_properties.py | 4 ++++ database_cleanup/tests/test_purge_tables.py | 3 +++ database_cleanup/views/purge_menus.xml | 2 +- 12 files changed, 37 insertions(+), 22 deletions(-) diff --git a/database_cleanup/models/purge_modules.py b/database_cleanup/models/purge_modules.py index f085b2374..e4726fde2 100644 --- a/database_cleanup/models/purge_modules.py +++ b/database_cleanup/models/purge_modules.py @@ -77,7 +77,7 @@ class CleanupPurgeWizardModule(models.TransientModel): { "name": module.name, } - ).purge() + ) continue res.append((0, 0, {"name": module.name})) diff --git a/database_cleanup/models/purge_wizard.py b/database_cleanup/models/purge_wizard.py index 2a6eb8bce..d862d490d 100644 --- a/database_cleanup/models/purge_wizard.py +++ b/database_cleanup/models/purge_wizard.py @@ -10,7 +10,7 @@ from odoo.exceptions import AccessDenied class CleanupPurgeLine(models.AbstractModel): - """ Abstract base class for the purge wizard lines """ + """Abstract base class for the purge wizard lines""" _name = "cleanup.purge.line" _order = "name" @@ -34,7 +34,7 @@ class CleanupPurgeLine(models.AbstractModel): class PurgeWizard(models.AbstractModel): - """ Abstract base class for the purge wizards """ + """Abstract base class for the purge wizards""" _name = "cleanup.purge.wizard" _description = "Purge stuff" diff --git a/database_cleanup/tests/common.py b/database_cleanup/tests/common.py index df9b17007..6449365d4 100644 --- a/database_cleanup/tests/common.py +++ b/database_cleanup/tests/common.py @@ -3,11 +3,8 @@ from odoo.modules.registry import Registry from odoo.tests import TransactionCase -from odoo.tests.common import tagged -# Use post_install to get all models loaded more info: odoo/odoo#13458 -@tagged("post_install", "-at_install") class Common(TransactionCase): def setUp(self): super(Common, self).setUp() diff --git a/database_cleanup/tests/test_create_indexes.py b/database_cleanup/tests/test_create_indexes.py index 4bfe6f2e7..70f0403f5 100644 --- a/database_cleanup/tests/test_create_indexes.py +++ b/database_cleanup/tests/test_create_indexes.py @@ -1,9 +1,13 @@ # Copyright 2021 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import tagged + from .common import Common +# Use post_install to get all models loaded more info: odoo/odoo#13458 +@tagged("post_install", "-at_install") class TestCreateIndexesLine(Common): def setUp(self): super(TestCreateIndexesLine, self).setUp() diff --git a/database_cleanup/tests/test_purge_columns.py b/database_cleanup/tests/test_purge_columns.py index c4b06a5a7..31dba2dcb 100644 --- a/database_cleanup/tests/test_purge_columns.py +++ b/database_cleanup/tests/test_purge_columns.py @@ -2,11 +2,14 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from psycopg2 import ProgrammingError +from odoo.tests.common import tagged from odoo.tools import mute_logger from .common import Common +# Use post_install to get all models loaded more info: odoo/odoo#13458 +@tagged("post_install", "-at_install") class TestCleanupPurgeLineColumn(Common): def setUp(self): super(TestCleanupPurgeLineColumn, self).setUp() diff --git a/database_cleanup/tests/test_purge_data.py b/database_cleanup/tests/test_purge_data.py index e979f13dc..b1f3f054c 100644 --- a/database_cleanup/tests/test_purge_data.py +++ b/database_cleanup/tests/test_purge_data.py @@ -1,9 +1,13 @@ # Copyright 2021 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import tagged + from .common import Common +# Use post_install to get all models loaded more info: odoo/odoo#13458 +@tagged("post_install", "-at_install") class TestCleanupPurgeLineData(Common): def setUp(self): super(TestCleanupPurgeLineData, self).setUp() diff --git a/database_cleanup/tests/test_purge_menus.py b/database_cleanup/tests/test_purge_menus.py index 4b5d26e99..65112b807 100644 --- a/database_cleanup/tests/test_purge_menus.py +++ b/database_cleanup/tests/test_purge_menus.py @@ -1,9 +1,13 @@ # Copyright 2021 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import tagged + from .common import Common +# Use post_install to get all models loaded more info: odoo/odoo#13458 +@tagged("post_install", "-at_install") class TestCleanupPurgeLineMenu(Common): def setUp(self): super(TestCleanupPurgeLineMenu, self).setUp() diff --git a/database_cleanup/tests/test_purge_models.py b/database_cleanup/tests/test_purge_models.py index 3e79f8f7a..996066769 100644 --- a/database_cleanup/tests/test_purge_models.py +++ b/database_cleanup/tests/test_purge_models.py @@ -1,9 +1,13 @@ # Copyright 2021 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import tagged + from .common import Common +# Use post_install to get all models loaded more info: odoo/odoo#13458 +@tagged("post_install", "-at_install") class TestCleanupPurgeLineColumn(Common): def setUp(self): super(TestCleanupPurgeLineColumn, self).setUp() @@ -22,7 +26,7 @@ class TestCleanupPurgeLineColumn(Common): self.env.registry.models.pop(self.model_name) def tearDown(self): - """ We recreate the model to avoid registry Exception at loading """ + """We recreate the model to avoid registry Exception at loading""" super(TestCleanupPurgeLineColumn, self).tearDown() # FIXME: issue origin is not clear but it must be addressed. self.model = self.env["ir.model"].create(self.model_values) diff --git a/database_cleanup/tests/test_purge_modules.py b/database_cleanup/tests/test_purge_modules.py index 3c8778a48..c361f7c61 100644 --- a/database_cleanup/tests/test_purge_modules.py +++ b/database_cleanup/tests/test_purge_modules.py @@ -1,12 +1,13 @@ # Copyright 2021 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -import threading -from odoo.tools import config +from odoo.tests.common import tagged from .common import Common +# Use post_install to get all models loaded more info: odoo/odoo#13458 +@tagged("post_install", "-at_install") class TestCleanupPurgeLineModule(Common): def setUp(self): super(TestCleanupPurgeLineModule, self).setUp() @@ -20,16 +21,7 @@ class TestCleanupPurgeLineModule(Common): def test_remove_to_upgrade_module(self): wizard = self.env["cleanup.purge.wizard.module"].create({}) - config.options["test_enable"] = False # Maybe useless now ?! - self.patch(threading.currentThread(), "testing", False) - wizard.purge_all() - config.options["test_enable"] = True # Maybe useless now ?! - self.patch(threading.currentThread(), "testing", True) - # must be removed by the wizard - self.assertFalse( - self.env["ir.module.module"].search( - [ - ("name", "=", "database_cleanup_test"), - ] - ) + module_names = wizard.purge_line_ids.filtered(lambda x: not x.purged).mapped( + "name" ) + self.assertTrue("database_cleanup_test" in module_names) diff --git a/database_cleanup/tests/test_purge_properties.py b/database_cleanup/tests/test_purge_properties.py index 589aecc4f..6cde440cc 100644 --- a/database_cleanup/tests/test_purge_properties.py +++ b/database_cleanup/tests/test_purge_properties.py @@ -1,9 +1,13 @@ # Copyright 2021 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import tagged + from .common import Common +# Use post_install to get all models loaded more info: odoo/odoo#13458 +@tagged("post_install", "-at_install") class TestCleanupPurgeLineProperty(Common): def setUp(self): super(TestCleanupPurgeLineProperty, self).setUp() diff --git a/database_cleanup/tests/test_purge_tables.py b/database_cleanup/tests/test_purge_tables.py index bf21177df..7b1119d04 100644 --- a/database_cleanup/tests/test_purge_tables.py +++ b/database_cleanup/tests/test_purge_tables.py @@ -2,11 +2,14 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from psycopg2 import ProgrammingError +from odoo.tests.common import tagged from odoo.tools import mute_logger from .common import Common +# Use post_install to get all models loaded more info: odoo/odoo#13458 +@tagged("post_install", "-at_install") class TestCleanupPurgeLineTable(Common): def setUp(self): super(TestCleanupPurgeLineTable, self).setUp() diff --git a/database_cleanup/views/purge_menus.xml b/database_cleanup/views/purge_menus.xml index 2209e7f71..8b6286c0f 100644 --- a/database_cleanup/views/purge_menus.xml +++ b/database_cleanup/views/purge_menus.xml @@ -15,7 +15,7 @@ code - action = env.get('cleanup.purge.wizard').get_wizard_action() + action = env.get('cleanup.purge.wizard.menu').get_wizard_action()