diff --git a/database_cleanup/models/purge_tables.py b/database_cleanup/models/purge_tables.py index 3f65f9926c0..1b5db6d3b7f 100644 --- a/database_cleanup/models/purge_tables.py +++ b/database_cleanup/models/purge_tables.py @@ -96,12 +96,16 @@ class CleanupPurgeWizardTable(models.TransientModel): _name = "cleanup.purge.wizard.table" _description = "Purge tables" + blacklist = [ + "endpoint_route", # web-api/endpoint_route_handler + ] + @api.model def find(self): """ Search for tables and views that cannot be instantiated. """ - known_tables = [] + known_tables = list(self.blacklist) for model in self.env["ir.model"].search([]): if model.model not in self.env: continue diff --git a/database_cleanup/tests/test_purge_tables.py b/database_cleanup/tests/test_purge_tables.py index a7bda839cec..b2a3bc57bcd 100644 --- a/database_cleanup/tests/test_purge_tables.py +++ b/database_cleanup/tests/test_purge_tables.py @@ -1,9 +1,8 @@ # Copyright 2021 Camptocamp SA # 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 odoo.tools import sql from .common import Common, environment @@ -17,7 +16,12 @@ def test_empty_table(self): env.cr.execute("create table database_cleanup_test (test int)") wizard = env["cleanup.purge.wizard.table"].create({}) wizard.purge_all() - with self.assertRaises(ProgrammingError): - with env.registry.cursor() as cr: - with mute_logger("odoo.sql_db"): - cr.execute("select * from database_cleanup_test") + self.assertFalse(sql.table_exists(env.cr, "database_cleanup_test")) + + def test_blacklist(self): + """A table mentioned in the blacklist is not purged""" + with environment() as env: + env.cr.execute("create table if not exists endpoint_route (test int)") + wizard = env["cleanup.purge.wizard.table"].create({}) + wizard.purge_all() + self.assertTrue(sql.table_exists(env.cr, "endpoint_route"))