Skip to content

[20.0][MIG] database_cleanup: Migration to 20.0 - #3898

Open
fetouaki-younes wants to merge 108 commits into
OCA:20.0from
fetouaki-younes:20.0-mig-database_cleanup
Open

fetouaki-younes wants to merge 108 commits into
OCA:20.0from
fetouaki-younes:20.0-mig-database_cleanup

Conversation

@fetouaki-younes

Copy link
Copy Markdown

Migration of database_cleanup from 19.0 to 20.0.

    Part of #3772
    
    ### Summary of changes
    - Ported commit history from `19.0`.
    - Applied XML formatting auto-fixes via `pre-commit` (`oca-checks-odoo-module`).
    - Bumped manifest version to `20.0.1.0.0` and converted `security/ir.model.access.csv` to `security/ir.access.csv` (`ir.access`).
    - Replaced `fa-times-circle text-danger` with Material Symbols (`icon="cancel"`, `icon_class="oi-filled text-danger"`) in `views/purge_line.xml`.
    - Removed `readme/CREDIT.md` reference to past financed migration.
    - Adapted `wizards/create_indexes.py` and `wizards/create_indexes_line.py` for Odoo 20.0 `ir.model.fields.index` selection (`btree`, `btree_not_null`, `trigram`) and
    `sql.create_index`.
    - Updated `tests/common.py` to keep registry signaling in-memory during tests (avoiding `Registry.new()` errors in Odoo 20.0) and fixed `store_fname` in `tests/test_purge_fields.py`.
    - Fixed `ruff` checks and regenerated `README.rst` and `static/description/index.html`.

Stefan Rijnhart and others added 30 commits December 2, 2026 09:13
avoid ''NoneType' object has no attribute 'exists'' error when purging models
fix my change guewen.baconnier@camptocamp.com-20140203103254-v1mzu2uib047xb9h, wrong lines replaced...
    raw SQL query (but never read afterwards). Workaround for
    lp:1277899

[FIX] Preserve dangling workflow table which is in use

[RFR] Group models per table when detecting columns to purge
      to prevent problems with models sharing the same table

[ADD] Allow purging of dangling data entries

[FIX] Data purging now working

[IMP] Docstrings

[FIX] Label
[FIX] Catch attempt to unlink field from nonexisting model

[RFR] Flake8
[CHG] database_cleanup: move description to README.rst
[IMP] order wizard lines by name

[IMP] deal with modules whose models can't be loaded

[IMP] double quotes for docstring

[FIX] use exists query instead of huge in list

[IMP] hide unnecessary buttons in wizard II

[IMP] readability

[FIX] cope with purging nonexisting models
[ADD] test purging modules

[ADD] test purging tables
[FIX] database_cleanup reloads the registry

which has weird side effects during testing. Take care
database_cleanup's tests don't mess up the following tests
* [FIX] database_cleanup: Isolate build
* Isolate `database_cleanup` into its own build in Travis file to fix OCA#689

* [FIX] database_cleanup: Remove KeyError assertion
* Remove KeyError assertion in tests due to PR in comment being merged
* [ADD] allow creating missing indexes

* [FIX] tests; installation

* [ADD] allow purging properties

* [ADD] missing file

* [ADD] test purging properties

* [ADD] missing parent_id for menu entry

* [FIX] don't delete too many and wrong properties
Using new base model inheritance.
[FIX] don't try to uninstall uninstalled modules

[DEL] weird code

[FIX] actually cleanup where we can
Update version number
Use correct import
Update .pot to match new syntax
Adapt icon to fontawesome
Add models description
Rename field external id to new syntax <model>__<field>
To match the new database_cleanup.pot
Following odoo/odoo@54238c88e85d6e a Many2many may have no relation
This avoids having a None record in the list (which is problematic with the
NOT IN clause)
https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_NOT_IN
OCA-git-bot and others added 26 commits December 2, 2026 09:13
Currently translated at 100.0% (81 of 81 strings)

Translation: server-tools-19.0/server-tools-19.0-database_cleanup
Translate-URL: https://translation.odoo-community.org/projects/server-tools-19-0/server-tools-19-0-database_cleanup/it/
Tests break on test attachment created without store_fname when `mail` is
installed. In that case, attachments are actively deleted when a model is
unlinked, and the missing store_fname causes problems further down.

https://github.com/odoo/odoo/blob/d2274a3fdb/addons/mail/models/ir_model.py#L50-L68

Fixes
```

2026-01-02 20:25:20,571 385 ERROR odoo odoo.tests.suite: ERROR: tearDownClass (odoo.addons.database_cleanup.tests.test_purge_fields.TestCleanupPurgeFields)
Traceback (most recent call last):
  File "/__w/server-tools/server-tools/database_cleanup/tests/test_purge_fields.py", line 65, in tearDownClass
    model.unlink()
  File "/opt/odoo/addons/mail/models/ir_model.py", line 68, in unlink
    self.env['ir.attachment']._file_delete(fname)
  File "/opt/odoo/odoo/addons/base/models/ir_attachment.py", line 162, in _file_delete
    self._mark_for_gc(fname)
  File "/opt/odoo/odoo/addons/base/models/ir_attachment.py", line 167, in _mark_for_gc
    fname = re.sub('[.:]', '', fname).strip('/\\')
  File "/usr/lib/python3.10/re.py", line 209, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object
```
…dels from group base.group_user to base.group_system
Currently translated at 54.3% (44 of 81 strings)

Translation: server-tools-19.0/server-tools-19.0-database_cleanup
Translate-URL: https://translation.odoo-community.org/projects/server-tools-19-0/server-tools-19-0-database_cleanup/sl/
Currently translated at 54.3% (44 of 81 strings)

Translation: server-tools-19.0/server-tools-19.0-database_cleanup
Translate-URL: https://translation.odoo-community.org/projects/server-tools-19-0/server-tools-19-0-database_cleanup/sl/
Currently translated at 100.0% (81 of 81 strings)

Translation: server-tools-19.0/server-tools-19.0-database_cleanup
Translate-URL: https://translation.odoo-community.org/projects/server-tools-19-0/server-tools-19-0-database_cleanup/sv/
Currently translated at 100.0% (81 of 81 strings)

Translation: server-tools-19.0/server-tools-19.0-database_cleanup
Translate-URL: https://translation.odoo-community.org/projects/server-tools-19-0/server-tools-19-0-database_cleanup/da/
Currently translated at 12.3% (10 of 81 strings)

Translation: server-tools-19.0/server-tools-19.0-database_cleanup
Translate-URL: https://translation.odoo-community.org/projects/server-tools-19-0/server-tools-19-0-database_cleanup/pl/
@oca-cla-bot

oca-cla-bot Bot commented Dec 2, 2026

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@OCA-git-bot OCA-git-bot added mod:database_cleanup Module database_cleanup series:20.0 labels Dec 2, 2026
@fetouaki-younes fetouaki-younes mentioned this pull request Dec 2, 2026
4 of 30 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.