Fix remove early initialization of res.{partner,company,users}#25
Merged
fkantelberg merged 2 commits intomasterfrom Mar 5, 2026
Merged
Fix remove early initialization of res.{partner,company,users}#25fkantelberg merged 2 commits intomasterfrom
fkantelberg merged 2 commits intomasterfrom
Conversation
This early initialization was there to prevent exceptions caused by fetching values of (newly added) fields of those models that were not yet present in the database, but had already been added to the model on the Python side. Unfortunately, this did run before any module migration. Consequently, a module's pre-migration, which should run before any module and module upgrade, did then run only after those models had already been updated. Also, the early initialization as implemented did already come too late. It had to run before `check_auto_install()`, but did run only in `update_changed()`, a couple of code lines later. In the end, it is unnecessary if `prefetch_fields=False` is in the context. But the `context_get()` does not put this entry into the context. This commit fixes all those issue. It makes the early initialization of the three models superfluous, and thus automatically let's the migration work as expected again.
Member
Author
|
Hint: Probably the code of OCA/server-tools#3487 needs to be adapted accordingly as well: - ctx = (
- odoo.api.Environment(cr, uid, {})["res.users"]
- .with_context(prefetch_fields=False)
- .context_get()
- )
+ ctx_prefetch = {"prefetch_fields": False}
+ ctx = odoo.api.Environment(cr, uid, ctx_prefetch)["res.users"].context_get()
+ ctx = dict(ctx)
+ ctx.update(ctx_prefetch) |
fkantelberg
approved these changes
Mar 5, 2026
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.
This early initialization was there to prevent exceptions caused by fetching values of (newly added) fields of those models that were not yet present in the database, but had already been added to the model on the Python side.
Unfortunately, this did run before any module migration. Consequently, a module's pre-migration, which should run before any module and module upgrade, did then run only after those models had already been updated.
Also, the early initialization as implemented did already come too late. It had to run before
check_auto_install(), but did run only inupdate_changed(), a couple of code lines later.In the end, it is unnecessary if
prefetch_fields=Falseis in the context.But the
context_get()does not put this entry into the context.This commit fixes all those issue. It makes the early initialization of the three models superfluous, and then removing it automatically let's the migration work as expected again.