-
Notifications
You must be signed in to change notification settings - Fork 28k
[IMP] core: support reinit modules #206408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The code seems ok, although it adds some complexity. The use case seems hacky to me. Reinitializing the module is quite extreme and seems for development only. Usually, just upgrade is enough during development. You can always dropdb (or uninstall) during development if you want to start from a clean state: reinitalizing could still leave some leftovers. If a module is already installed, nothing should happen. |
Maybe if I have to fix a customer's database, but I am not sure if it is because of modified configurations/data, e.g. security rules, email templates. I can use the reinit feature to rollback those configurations and check if the bug can be reproduced. Use case from @tde-banana-odoo |
e542d46
to
9a66cb5
Compare
If there is a demand for it, then a new command could be added. |
9a66cb5
to
b1fdc18
Compare
a93bdf0
to
98d77ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I like that we expose a dedicated option for that. Don't forget the documentation PR!
content/developer/reference/backend/orm/changelog.rst
content/developer/reference/cli.rst
98d77ed
to
aad11fa
Compare
aad11fa
to
5bf68f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robodoo rebase-ff
Merge method set to rebase and fast-forward. |
5bf68f4
to
2a0e865
Compare
2a0e865
to
2b38b84
Compare
if reinit_modules: | ||
modules = Module.search([('state', 'in', ('installed', 'to upgrade')), ('name', 'in', tuple(reinit_modules))]) | ||
reinit_modules = modules.downstream_dependencies(exclude_states=('uninstalled', 'uninstallable', 'to remove', 'to install')) + modules | ||
registry._reinit_modules.update(m for m in reinit_modules.mapped('name') if m not in graph._imported_modules) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand it correctly, this code ensures that if module A is reinitialized, then all modules that depend on A are reinitialized, too. Am I correct? If so, maybe add a comment line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the downstream_dependencies
can explain the concept well.
And as I worte in the doc of Registry.new
and odoo/documentation#13222. The reinit
is a simple upgrade
nut loading data with 'init'
mode, and all mdoules depending on it will also be reinitizlized.
Before odoo#189000, -i an already installed module will reinitialize the module 1. reinstall the module without ``pre/post_init_hook`` 2. reinitialize some(but not all) of its direct or indirect dependent installed modules odoo#189000 removed the behavior, because it is not correct. As a result, -i does nothing to an installed module. Although the behavior was not correct and had some side effects, it was useful for developers or a quick database fix. This commit re-supports the feature and defines the ```reinit`` as a special upgrade 1. doesn't execute ``migration scripts`` 2. load data in ``'init'`` mode
2b38b84
to
5c6ac5d
Compare
Before #189000, -i an already installed module will reinitialize the module
pre/post_init_hook
Although the behavior was not correct and had some side effects, it is useful for developers or a quick database fix.
This commit re-supports the feature and defines the
reinit
as a special upgrademigration scripts
'init'
modeThe difference between
registry._force_upgrade_scripts
(by upgrade hacks)
registry._reinit_modules
(by
-i m -u m
which should have same result as
-i m
)odoo/documentation#13222
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr