[18.0][IMP] server_environment: Preserve not env managed data#264
Open
[18.0][IMP] server_environment: Preserve not env managed data#264
Conversation
65f05d6 to
f772104
Compare
sbidoul
reviewed
Apr 2, 2026
| return | ||
|
|
||
| @api.model | ||
| def preserve_not_env_managed_data(self): |
Member
There was a problem hiding this comment.
Suggested change
| def preserve_not_env_managed_data(self): | |
| def _preserve_not_env_managed_data(self): |
If this is to be used in migration scripts, maybe it's safer to pass the list of fields/columns to handle explicitly?
f772104 to
51885bd
Compare
Helper function typically used for hooks and migration scripts. Restores database values for fields transitioning to 'server env managed'. When a field is defined as managed by the server environment, Odoo ignores the value stored in the database, prioritizing the environment configuration instead. If no environment configuration exists, the field may effectively lose its previous value. This method forces to 'persist' these values if they are not explicitly overridden by the current environment configuration.
51885bd to
7bec03f
Compare
…cation" To preserve the value of field "smtp_authentication" if we don't set it from the environment. Which may happen to anyone updating the sources of mail_environment for its project.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Heavily inspired from #219, thank you @rven for your contribution.
I wanted to make @rven script more generic because this problem potentially happens every time we add the
server.env.mixinto a model or when we add fields to the_server_env_fields()list.Helper function typically used for hooks and migration scripts.
Restores database values for fields transitioning to 'server env managed'.
When a field is defined as managed by the server environment, Odoo ignores the value stored in the database, prioritizing the environment configuration instead. If no environment configuration exists, the field may effectively lose its previous value.
This method forces to 'persist' these values if they are not explicitly overridden by the current environment configuration.