[15.0][FIX] database_cleanup: Prevent deletion of columns added in the init method of the model #2994
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #2852 (backported for 14.0 in #2993), but with proper commit message.
With Odoo 16.0, running the "Purge columns" database cleanup, a field called totp_secret shows up for purging when the auth_totp module is installed. This field seems to be defined as a computed non-stored field
(https://github.com/odoo/odoo/blob/93aa48c972889f941b97a60738d33f571204bb2c/addons/auth_totp/models/res_users.py#L24), but also has a query referring to it.
(https://github.com/odoo/odoo/blob/93aa48c972889f941b97a60738d33f571204bb2c/addons/auth_totp/models/res_users.py#L160)
The totp_secret field would have to be defined as stored=True, but it is not defined as such. Instead, it's added in res.users init method:
https://github.com/odoo/odoo/blob/93aa48c972889f941b97a60738d33f571204bb2c/addons/auth_totp/models/res_users.py#L32
The solution is to add the "totp_secret" field to the blacklisted fields of res.users.
@Tecnativa