Skip to content

Commit 189d802

Browse files
committed
Merge PR OCA#3240 into 18.0
Signed-off-by pedrobaeza
2 parents 0590408 + 2a77866 commit 189d802

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

database_cleanup/models/purge_tables.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,16 @@ class CleanupPurgeWizardTable(models.TransientModel):
9696
_name = "cleanup.purge.wizard.table"
9797
_description = "Purge tables"
9898

99+
blacklist = [
100+
"endpoint_route", # web-api/endpoint_route_handler
101+
]
102+
99103
@api.model
100104
def find(self):
101105
"""
102106
Search for tables and views that cannot be instantiated.
103107
"""
104-
known_tables = []
108+
known_tables = list(self.blacklist)
105109
for model in self.env["ir.model"].search([]):
106110
if model.model not in self.env:
107111
continue
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# Copyright 2021 Camptocamp SA
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3-
from psycopg2 import ProgrammingError
43

54
from odoo.tests.common import tagged
6-
from odoo.tools import mute_logger
5+
from odoo.tools import sql
76

87
from .common import Common, environment
98

@@ -17,7 +16,12 @@ def test_empty_table(self):
1716
env.cr.execute("create table database_cleanup_test (test int)")
1817
wizard = env["cleanup.purge.wizard.table"].create({})
1918
wizard.purge_all()
20-
with self.assertRaises(ProgrammingError):
21-
with env.registry.cursor() as cr:
22-
with mute_logger("odoo.sql_db"):
23-
cr.execute("select * from database_cleanup_test")
19+
self.assertFalse(sql.table_exists(env.cr, "database_cleanup_test"))
20+
21+
def test_blacklist(self):
22+
"""A table mentioned in the blacklist is not purged"""
23+
with environment() as env:
24+
env.cr.execute("create table if not exists endpoint_route (test int)")
25+
wizard = env["cleanup.purge.wizard.table"].create({})
26+
wizard.purge_all()
27+
self.assertTrue(sql.table_exists(env.cr, "endpoint_route"))

0 commit comments

Comments
 (0)