Skip to content

Commit b68617c

Browse files
author
Stephane Mangin
committed
[MIG] database_cleanup: Migration to 14.0
1 parent 99fcae3 commit b68617c

28 files changed

+411
-222
lines changed

database_cleanup/README.rst

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
1-
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
1+
===================
2+
Base Technical User
3+
===================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
214
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
315
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
17+
:target: https://github.com/OCA/server-tools/tree/14.0/database_cleanup
18+
:alt: OCA/server-tools
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-database_cleanup
21+
:alt: Translate me on Weblate
22+
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23+
:target: https://runbot.odoo-community.org/runbot/149/14.0
24+
:alt: Try me on Runbot
425

5-
================
6-
Database cleanup
7-
================
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
827

928
Clean your Odoo database from remnants of modules, models, columns and
1029
tables left by uninstalled modules (prior to 7.0) or a homebrew database
@@ -16,6 +35,11 @@ with the technical details of the Odoo data model of *all* the modules
1635
that have ever been installed on your database, and do not purge any module,
1736
model, column or table if you do not know exactly what you are doing.
1837

38+
**Table of contents**
39+
40+
.. contents::
41+
:local:
42+
1943
Usage
2044
=====
2145

@@ -28,42 +52,46 @@ in one big step (if you are *really* confident).
2852

2953
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
3054
:alt: Try me on Runbot
31-
:target: https://runbot.odoo-community.org/runbot/149/11.0
55+
:target: https://runbot.odoo-community.org/runbot/149/14.0
3256

3357
Bug Tracker
3458
===========
3559

36-
Bugs are tracked on `GitHub Issues <https://github.com/OCA/database_cleanup/issues>`_.
60+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
3761
In case of trouble, please check there if your issue has already been reported.
38-
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.
62+
If you spotted it first, help us smashing it by providing a detailed and welcomed
63+
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20database_cleanup%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
64+
65+
Do not contact contributors directly about support or help with technical issues.
3966

4067
Credits
4168
=======
4269

43-
Images
44-
------
70+
Authors
71+
~~~~~~~
4572

46-
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
73+
* Therp BV
4774

4875
Contributors
49-
------------
76+
~~~~~~~~~~~~
5077

5178
* Stefan Rijnhart <stefan@opener.amsterdam>
5279
* Holger Brunn <hbrunn@therp.nl>
80+
* Stéphane Mangin <stephane.mangin@camptocamp.com>
5381

54-
Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list <mailto:community@mail.odoo.com>`_ or the `appropriate specialized mailinglist <https://odoo-community.org/groups>`_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues.
82+
Maintainers
83+
~~~~~~~~~~~
5584

56-
Maintainer
57-
----------
85+
This module is maintained by the OCA.
5886

5987
.. image:: https://odoo-community.org/logo.png
6088
:alt: Odoo Community Association
6189
:target: https://odoo-community.org
6290

63-
This module is maintained by the OCA.
64-
6591
OCA, or the Odoo Community Association, is a nonprofit organization whose
6692
mission is to support the collaborative development of Odoo features and
6793
promote its widespread use.
6894

69-
To contribute to this module, please visit https://odoo-community.org.
95+
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/14.0/base_technical_user>`_ project on GitHub.
96+
97+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Copyright 2014-2016 Therp BV <http://therp.nl>
2+
# Copyright 2021 Camptocamp SA <https://camptocamp.com>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34
{
45
"name": "Database cleanup",
5-
"version": "12.0.1.0.1",
6+
"version": "14.0.1.0.0",
67
"author": "Therp BV,Odoo Community Association (OCA)",
8+
"website": "https://github.com/OCA/server-tools",
79
"depends": ["base"],
810
"license": "AGPL-3",
911
"category": "Tools",
@@ -18,6 +20,7 @@
1820
"views/create_indexes.xml",
1921
"views/purge_properties.xml",
2022
"views/menu.xml",
23+
"security/ir.model.access.csv",
2124
],
2225
"installable": True,
2326
}

database_cleanup/i18n/en.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ msgstr "Purge obsolete modules"
457457
#, fuzzy
458458
#| msgid "Purge obsolete models"
459459
msgid "Purge obsolete properties"
460-
msgstr "Purge obsolete models"
460+
msgstr "Purge obsolete properties"
461461

462462
#. module: database_cleanup
463463
#: model:ir.ui.menu,name:database_cleanup.menu_purge_tables

database_cleanup/models/create_indexes.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# Copyright 2017 Therp BV <http://therp.nl>
2+
# Copyright 2021 Camptocamp <https://camptocamp.com>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34
# pylint: disable=consider-merging-classes-inherited
4-
from odoo import api, fields, models
5+
from odoo import fields, models
56

67
from ..identifier_adapter import IdentifierAdapter
78

89

910
class CreateIndexesLine(models.TransientModel):
1011
_inherit = "cleanup.purge.line"
1112
_name = "cleanup.create_indexes.line"
13+
_description = "Cleanup Create Indexes line"
1214

1315
purged = fields.Boolean("Created")
1416
wizard_id = fields.Many2one("cleanup.create_indexes.wizard")
1517
field_id = fields.Many2one("ir.model.fields", required=True)
1618

17-
@api.multi
1819
def purge(self):
19-
tables = set()
2020
for field in self.mapped("field_id"):
2121
model = self.env[field.model]
2222
name = "{}_{}_index".format(model._table, field.name)
@@ -28,8 +28,6 @@ def purge(self):
2828
IdentifierAdapter(field.name),
2929
),
3030
)
31-
tables.add(model._table)
32-
for table in tables:
3331
self.env.cr.execute("analyze %s", (IdentifierAdapter(model._table),))
3432
self.write(
3533
{
@@ -48,7 +46,6 @@ class CreateIndexesWizard(models.TransientModel):
4846
"wizard_id",
4947
)
5048

51-
@api.multi
5249
def find(self):
5350
res = list()
5451
for field in self.env["ir.model.fields"].search(

database_cleanup/models/purge_columns.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2014-2016 Therp BV <http://therp.nl>
2+
# Copyright 2021 Camptocamp <https://camptocamp.com>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34
# pylint: disable=consider-merging-classes-inherited
45
from odoo import _, api, fields, models
@@ -10,14 +11,13 @@
1011
class CleanupPurgeLineColumn(models.TransientModel):
1112
_inherit = "cleanup.purge.line"
1213
_name = "cleanup.purge.line.column"
13-
_description = "Purge Column Wizard Lines"
14+
_description = "Cleanup Purge Line Column"
1415

1516
model_id = fields.Many2one("ir.model", "Model", required=True, ondelete="CASCADE")
1617
wizard_id = fields.Many2one(
1718
"cleanup.purge.wizard.column", "Purge Wizard", readonly=True
1819
)
1920

20-
@api.multi
2121
def purge(self):
2222
"""
2323
Unlink columns upon manual confirmation.
@@ -123,7 +123,7 @@ def find(self):
123123
model_pool
124124
)
125125

126-
for table, model_spec in table2model.items():
126+
for _table, model_spec in table2model.items():
127127
for column in self.get_orphaned_columns(model_spec[1]):
128128
res.append((0, 0, {"name": column, "model_id": model_spec[0]}))
129129
if not res:

database_cleanup/models/purge_data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2014-2016 Therp BV <http://therp.nl>
2+
# Copyright 2021 Camptocamp <https://camptocamp.com>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34
from odoo import _, api, fields, models
45
from odoo.exceptions import UserError
@@ -9,13 +10,13 @@
910
class CleanupPurgeLineData(models.TransientModel):
1011
_inherit = "cleanup.purge.line"
1112
_name = "cleanup.purge.line.data"
13+
_description = "Cleanup Purge Line Data"
1214

1315
data_id = fields.Many2one("ir.model.data", "Data entry")
1416
wizard_id = fields.Many2one(
1517
"cleanup.purge.wizard.data", "Purge Wizard", readonly=True
1618
)
1719

18-
@api.multi
1920
def purge(self):
2021
"""Unlink data entries upon manual confirmation."""
2122
if self:

database_cleanup/models/purge_menus.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2014-2016 Therp BV <http://therp.nl>
2+
# Copyright 2021 Camptocamp <https://camptocamp.com>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34
# pylint: disable=consider-merging-classes-inherited
45
from odoo import _, api, fields, models
@@ -8,13 +9,13 @@
89
class CleanupPurgeLineMenu(models.TransientModel):
910
_inherit = "cleanup.purge.line"
1011
_name = "cleanup.purge.line.menu"
12+
_description = "Cleanup Purge Line Menu"
1113

1214
wizard_id = fields.Many2one(
1315
"cleanup.purge.wizard.menu", "Purge Wizard", readonly=True
1416
)
1517
menu_id = fields.Many2one("ir.ui.menu", "Menu entry")
1618

17-
@api.multi
1819
def purge(self):
1920
"""Unlink menu entries upon manual confirmation."""
2021
if self:
@@ -47,9 +48,7 @@ def find(self):
4748
):
4849
if menu.action.type != "ir.actions.act_window":
4950
continue
50-
if (menu.action.res_model and menu.action.res_model not in self.env) or (
51-
menu.action.src_model and menu.action.src_model not in self.env
52-
):
51+
if menu.action.res_model and menu.action.res_model not in self.env:
5352
res.append(
5453
(
5554
0,

database_cleanup/models/purge_models.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2014-2016 Therp BV <http://therp.nl>
2+
# Copyright 2021 Camptocamp <https://camptocamp.com>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34
# pylint: disable=consider-merging-classes-inherited
45
from odoo import _, api, fields, models
@@ -25,7 +26,6 @@ def _inherited_models(self):
2526
class IrModelFields(models.Model):
2627
_inherit = "ir.model.fields"
2728

28-
@api.multi
2929
def _prepare_update(self):
3030
"""this function crashes for undefined models"""
3131
existing = self.filtered(lambda x: x.model in self.env)
@@ -35,13 +35,12 @@ def _prepare_update(self):
3535
class CleanupPurgeLineModel(models.TransientModel):
3636
_inherit = "cleanup.purge.line"
3737
_name = "cleanup.purge.line.model"
38-
_description = "Purge models"
38+
_description = "Cleanup Purge Line Model"
3939

4040
wizard_id = fields.Many2one(
4141
"cleanup.purge.wizard.model", "Purge Wizard", readonly=True
4242
)
4343

44-
@api.multi
4544
def purge(self):
4645
"""
4746
Unlink models upon manual confirmation.

database_cleanup/models/purge_modules.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2014-2016 Therp BV <http://therp.nl>
2+
# Copyright 2021 Camptocamp <https://camptocamp.com>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34
# pylint: disable=consider-merging-classes-inherited
45
from odoo import _, api, fields, models
@@ -33,12 +34,12 @@ def _module_data_uninstall(self, modules_to_remove):
3334
class CleanupPurgeLineModule(models.TransientModel):
3435
_inherit = "cleanup.purge.line"
3536
_name = "cleanup.purge.line.module"
37+
_description = "Cleanup Purge Line Module"
3638

3739
wizard_id = fields.Many2one(
3840
"cleanup.purge.wizard.module", "Purge Wizard", readonly=True
3941
)
4042

41-
@api.multi
4243
def purge(self):
4344
"""
4445
Uninstall modules upon manual confirmation, then reload

database_cleanup/models/purge_properties.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# Copyright 2017 Therp BV <http://therp.nl>
2+
# Copyright 2021 Camptocamp <https://camptocamp.com>
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34
# pylint: disable=consider-merging-classes-inherited
45
from odoo import api, fields, models
56

6-
REASON_DUPLICATE = 1
7-
REASON_DEFAULT = 2
8-
REASON_DEFAULT_FALSE = 3
9-
REASON_UNKNOWN_MODEL = 4
7+
REASON_DUPLICATE = "REASON_DUPLICATE"
8+
REASON_DEFAULT = "REASON_DEFAULT"
9+
REASON_DEFAULT_FALSE = "REASON_DEFAULT_FALSE"
10+
REASON_UNKNOWN_MODEL = "REASON_UNKNOWN_MODEL"
1011

1112

1213
class CleanupPurgeLineProperty(models.TransientModel):
1314
_inherit = "cleanup.purge.line"
1415
_name = "cleanup.purge.line.property"
15-
_description = "Purge properties"
16+
_description = "Cleanup Purge Line Property"
1617

1718
wizard_id = fields.Many2one(
1819
"cleanup.purge.wizard.property", "Purge Wizard", readonly=True
@@ -27,7 +28,6 @@ class CleanupPurgeLineProperty(models.TransientModel):
2728
]
2829
)
2930

30-
@api.multi
3131
def purge(self):
3232
"""Delete properties"""
3333
self.write({"purged": True})
@@ -58,12 +58,7 @@ def find(self):
5858
except KeyError:
5959
result.append(
6060
{
61-
"name": "%s@%s: %s"
62-
% (
63-
prop.name,
64-
prop.res_id,
65-
value,
66-
),
61+
"name": "{}@{}: {}".format(prop.name, prop.res_id, value),
6762
"property_id": prop.id,
6863
"reason": REASON_UNKNOWN_MODEL,
6964
}
@@ -72,12 +67,7 @@ def find(self):
7267
if not value:
7368
result.append(
7469
{
75-
"name": "%s@%s: %s"
76-
% (
77-
prop.name,
78-
prop.res_id,
79-
value,
80-
),
70+
"name": "{}@{}: {}".format(prop.name, prop.res_id, value),
8171
"property_id": prop.id,
8272
"reason": REASON_DEFAULT_FALSE,
8373
}
@@ -127,8 +117,9 @@ def find(self):
127117
for redundant_property in self.env["ir.property"].search(domain):
128118
result.append(
129119
{
130-
"name": "%s@%s: %s"
131-
% (prop.name, redundant_property.res_id, prop.get_by_record()),
120+
"name": "{}@{}: {}".format(
121+
prop.name, redundant_property.res_id, prop.get_by_record()
122+
),
132123
"property_id": redundant_property.id,
133124
"reason": REASON_DEFAULT,
134125
}
@@ -148,8 +139,9 @@ def find(self):
148139
for prop in self.env["ir.property"].search([("id", "in", ids)])[1:]:
149140
result.append(
150141
{
151-
"name": "%s@%s: %s"
152-
% (prop.name, prop.res_id, prop.get_by_record()),
142+
"name": "{}@{}: {}".format(
143+
prop.name, prop.res_id, prop.get_by_record()
144+
),
153145
"property_id": prop.id,
154146
"reason": REASON_DUPLICATE,
155147
}

0 commit comments

Comments
 (0)