Description
Hi!
When upgrading to 17.0 there is new dependency of custom module that I want to install in pre-migration of base module.
But util.modules
is not imported correctly in pre- migration but works in post-.
util.modules.module_installed(cr, 'my_custom_module')
gives following error
AttributeError: module 'odoo.modules' has no attribute 'module_installed'
My setup is following:
After upgrading the database from 15.0 to 17.0 via python <(curl -s https://upgrade.odoo.com/upgrade) test -d <your db name> -t <target version>
It is restored to continue migration of custom modules.
Everything happens inside docker container.
Odoo is installed at /usr/lib/python3/dist-packages/odoo
Upgrade util is installed at /usr/local/lib/python3.10/dist-packages/odoo/upgrade
via sudo -H pip3 install --upgrade git+https://github.com/odoo/upgrade-util@master
Custom upgrade script is located at /mnt/extra-addons/upgrades/base/16.0.1.3/pre-install_new_deps.py
from odoo.upgrade import util
def migrate(cr, version):
if util.modules.module_installed(cr, 'my_custom_module'):
util.modules.new_module_dep(cr, 'my_custom_module', 'new_dep_module')
With psql I reset base version (as it is 17.0.1.3 after upgrade.odoo.com) to trigger our upgrade scripts
update ir_module_module set state='to upgrade', latest_version='15.0.1.3' where name='base';
And start odoo
UPG_AUTOINSTALL='all' odoo -u all -d odoo --upgrade-path=/usr/local/lib/python3.10/dist-packages/odoo/upgrade,/mnt/extra-addons/upgrades --stop-after-init
If I set the breakpoint at upgrade script and check util there it can be seen that modules attribute is imported from odoo modules not from util so the script fails.
However it works in base/0.0.0/post-install_new_deps.py
for some reason but it's too late for modules operations.
