-
Notifications
You must be signed in to change notification settings - Fork 61
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
Fix dependencies expansion: handle active=True correctly #93
base: master
Are you sure you want to change the base?
Conversation
@sbidoul are the test errors related to this change? |
The test failures are not related. We'll need a new test for this case though. |
da36cee
to
1abcc06
Compare
Ok, I added a simple test with this situation in particular, I don't know if it is the best way of testing this, but it tests at least this specific situation. |
@joao-p-marques thanks for the fix! Can you rebase and add a I don't know why we decided to handle active differently than auto_install in #9. That's weird. |
1abcc06
to
2f0a3c2
Compare
Ok @sbidoul Thanks! I just added |
Codecov Report
@@ Coverage Diff @@
## master #93 +/- ##
==========================================
- Coverage 93.16% 93.12% -0.04%
==========================================
Files 14 14
Lines 892 887 -5
Branches 157 154 -3
==========================================
- Hits 831 826 -5
Misses 43 43
Partials 18 18
Continue to review full report at Codecov.
|
No that's fine, it will be updated when releasing. Still I have doubts that auto_install and active mean exactly the same. For instance in the Odoo documentation, they are distinct entries. Is that a documentation bug ? I'd really like a test that reproduces the bug. |
I think the documentation is buggy, at least from reading the code I mention above. The test I add should assert that, at least for v13 and v14. |
I'm patching the docs in odoo/documentation#1109 to clarify this situation. This fix has been in production for months, is all green and has proper docs and tests. IMHO this can be merged. |
@sbidoul any news on this? Could it be merged? |
I'm still have doubts. For instance if l10n_fi is active = auto_install = True, why does it not auto install when we install account ? |
It has been some time since I've looked into it, but I think what you are saying is exactly what I am doing here. If However, the current behavior, is that it is always included, even if its dependencies are not installed (like |
What I mean is that l10n_fi does not auto install in my databases when I do "odoo -i account", so active must be doing something different than auto_install ? |
Oh, I see... I think it is because Odoo defaults I guess that is another bug, as by looking at the code you can see they should have the same behavior... In that case, we can either leave this as is, or simply ignore the |
It seems the docs have settled in odoo/documentation#1427. I'd say the patch is incomplete because it doesn't contemplate situations where |
Thanks for the reference @yajo I will work on the necessary changes 👍 |
2f0a3c2
to
8482199
Compare
@yajo @sbidoul taking into account the latest updates to the documentation, and also what I mentioned in #93 (comment) about the actual usage of the
|
…orrectly According to the updated documentation, active=True in a module's manifest is a deprecated equivalent to auto_install=True: odoo/odoo@2cc7f0d#diff-367842087e68d6811cf53f2ab3eb21103cd8e793b1648ef3e57f220ee0ccde4eL345 https://www.odoo.com/documentation/15.0/developer/reference/backend/module.html it does not mean that Odoo installs it automatically, as mentioned in acsone#9 OTOH, currently Odoo ignores it. See: https://github.com/odoo/odoo/blob/13.0/odoo/modules/module.py#L335 https://github.com/odoo/odoo/blob/13.0/odoo/modules/module.py#L370 So, we should ignore that key. Besides, this implements the more complex functionality of defining auto_install as a subset of the module's dependencies, as also explained in the documentation. Also, add a new simple test for this case.
8482199
to
01f6d5e
Compare
This has been more than half a year in production. Can't we merge? |
Hello @sbidoul! 👋🏼 Any chances for a new review and merge? |
@sbidoul coming again to this. Can this be merged? |
if include_auto_install: | ||
auto_install_list = [] | ||
for module_name in sorted(odoo.modules.module.get_modules()): | ||
module_path = odoo.modules.get_module_path(module_name) | ||
manifest = read_manifest(module_path) | ||
if manifest.get("auto_install"): | ||
# "auto_install" can be a list or a boolean | ||
# see Odoo's documentation for Module Manifests |
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.
This part seems unrelated to the issue, and should be best done in another PR.
BTW, where is this documented?
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.
NVM, I found the comment in the Odoo codebase.
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.
Tell me and I put the link here as reference.
@@ -0,0 +1,3 @@ | |||
Fix dependencies expansion: handle active=True correctly | |||
`active=True` in a module's manifest is a deprecated equivalent to `auto_install=True`, | |||
so we should handle that key the same way we handle the `auto_install` one. |
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.
This description is incorrect? If I read the PR correctly, it ignores the active
flag so it does not handle it the same way as auto_install.
if ( | ||
isinstance(auto_install, list) | ||
and ( | ||
manifest.get("auto_install") == [] |
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.
This does not look right. If auto_install
is an empty list, the module should be installed unconditionally, so in that case it should be add_deps(module_name)
.
@pedrobaeza I read this again and I found a couple of issues, I think. Also, it seem Odoo 12 still supported the active flag, so we should skip the check for active for Odoo >= 13. |
OK, seeing that this is not direct at all, we can leave it on hold, and I'll come back to this later with less workload, and also not being something terrible. I haven't found a manifest with Thank you very much for reviewing it. I'll tell you when the changes are done. |
Indeed :) Actually I think the real bug is that we don't support |
(cherry picked from commit 59264de)
active=True
in a module's manifest is a deprecated equivalent toauto_install=True
:odoo/odoo@2cc7f0d#diff-367842087e68d6811cf53f2ab3eb21103cd8e793b1648ef3e57f220ee0ccde4eL345
It does not mean that Odoo installs it automatically, as mentioned in #9
Instead, we should handle that key the same way we handle the
auto_install
one.To reproduce
In v13 or v14, there is a localization module with
active
set toTrue
: https://github.com/odoo/odoo/blob/13.0/addons/l10n_fi/__manifest__.py#L39If we did
click-odoo-initdb -n devel -m base
,l10n_fi
was added to the list of modules to generate the hash, along with its dependencies (one of them isaccount
). However, after the initialization of the DB, Odoo did not install that module, which made that hash incorrect.If we, then, removed the DB (
click-odoo-dropdb devel
) and initialized it again withaccount
(click-odoo-initdb -n devel -m base,account
) the result was that a DB cache was restored (because the previous hash includedaccount
) when, however,account
was never installed in the DB.@Tecnativa
TT24972
ping @yajo