diff --git a/database_cleanup/__manifest__.py b/database_cleanup/__manifest__.py index c4f111361..f119f40b1 100644 --- a/database_cleanup/__manifest__.py +++ b/database_cleanup/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Database cleanup", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "author": "Therp BV,Odoo Community Association (OCA)", "website": "https://github.com/OCA/server-tools", "depends": ["base"], diff --git a/database_cleanup/models/create_indexes.py b/database_cleanup/models/create_indexes.py index 5f92d6e53..cee600d3d 100644 --- a/database_cleanup/models/create_indexes.py +++ b/database_cleanup/models/create_indexes.py @@ -19,7 +19,7 @@ class CreateIndexesLine(models.TransientModel): def purge(self): for field in self.mapped("field_id"): model = self.env[field.model] - name = f"{model._table}_{field.name}_index" + name = f"{model._table}__{field.name}_index" self.env.cr.execute( "create index %s ON %s (%s)", ( @@ -56,7 +56,7 @@ class CreateIndexesWizard(models.TransientModel): if field.model not in self.env.registry: continue model = self.env[field.model] - name = f"{model._table}_{field.name}_index" + name = f"{model._table}__{field.name}_index" self.env.cr.execute( "select indexname from pg_indexes " "where indexname=%s and tablename=%s", diff --git a/database_cleanup/models/purge_data.py b/database_cleanup/models/purge_data.py index c42182e5e..e67a6117a 100644 --- a/database_cleanup/models/purge_data.py +++ b/database_cleanup/models/purge_data.py @@ -78,8 +78,7 @@ class CleanupPurgeWizardData(models.TransientModel): 0, { "data_id": data.id, - "name": "%s.%s, object of type %s" - % (data.module, data.name, data.model), + "name": f"{data.module}.{data.name}, object of type {data.model}", }, ) ) diff --git a/database_cleanup/models/purge_properties.py b/database_cleanup/models/purge_properties.py index baf37a4e2..3ae76f67c 100644 --- a/database_cleanup/models/purge_properties.py +++ b/database_cleanup/models/purge_properties.py @@ -103,8 +103,9 @@ class CleanupPurgeWizardProperty(models.TransientModel): "id", "not in", default_properties.filtered( - lambda x: x.company_id - and x.fields_id == prop.fields_id + lambda x, + prop_fields_id=prop.fields_id: x.company_id + and x.fields_id == prop_fields_id ).ids, ) ] diff --git a/database_cleanup/models/purge_wizard.py b/database_cleanup/models/purge_wizard.py index 87e1ca460..456ee524a 100644 --- a/database_cleanup/models/purge_wizard.py +++ b/database_cleanup/models/purge_wizard.py @@ -25,7 +25,7 @@ class CleanupPurgeLine(models.AbstractModel): def purge(self): raise NotImplementedError - @api.model + @api.model_create_multi def create(self, values): # make sure the user trying this is actually supposed to do it if self.env.ref("base.group_erp_manager") not in self.env.user.groups_id: @@ -77,10 +77,11 @@ class PurgeWizard(models.AbstractModel): "domain": [("wizard_id", "in", self.ids)], } - def name_get(self): - return [(this.id, self._description) for this in self] + def _compute_display_name(self): + for this in self: + this.display_name = self._description - @api.model + @api.model_create_multi def create(self, values): # make sure the user trying this is actually supposed to do it if self.env.ref("base.group_erp_manager") not in self.env.user.groups_id: diff --git a/database_cleanup/static/description/index.html b/database_cleanup/static/description/index.html index 8468972fb..5cff82a36 100644 --- a/database_cleanup/static/description/index.html +++ b/database_cleanup/static/description/index.html @@ -1,4 +1,3 @@ - diff --git a/database_cleanup/tests/test_create_indexes.py b/database_cleanup/tests/test_create_indexes.py index 52454c5eb..eed4e5334 100644 --- a/database_cleanup/tests/test_create_indexes.py +++ b/database_cleanup/tests/test_create_indexes.py @@ -13,7 +13,7 @@ class TestCreateIndexesLine(Common): super().setUp() with environment() as env: # delete some index and check if our module recreated it - env.cr.execute("drop index res_partner_name_index") + env.cr.execute("drop index res_partner__name_index") def test_deleted_index(self): with environment() as env: @@ -21,6 +21,6 @@ class TestCreateIndexesLine(Common): wizard.purge_all() env.cr.execute( "select indexname from pg_indexes where " - "indexname='res_partner_name_index' and tablename='res_partner' " + "indexname='res_partner__name_index' and tablename='res_partner' " ) self.assertEqual(env.cr.rowcount, 1) diff --git a/database_cleanup/views/purge_wizard.xml b/database_cleanup/views/purge_wizard.xml index f7342d1e6..ad977f1c9 100644 --- a/database_cleanup/views/purge_wizard.xml +++ b/database_cleanup/views/purge_wizard.xml @@ -13,13 +13,10 @@ />