@@ -501,10 +501,10 @@ def _up(table, old, new):
501501 cr .execute ("DELETE FROM ir_module_module_dependency WHERE name=%s" , [old ])
502502 cr .execute ("DELETE FROM ir_model_data WHERE model='ir.module.module' AND res_id=%s" , [mod_ids [old ]])
503503 if state in INSTALLED_MODULE_STATES :
504- force_install_module (cr , into )
504+ force_install_module (cr , into , reason = "installed {!r} module has been merged into it" . format ( old ) )
505505
506506
507- def force_install_module (cr , module , if_installed = None ):
507+ def force_install_module (cr , module , if_installed = None , reason = "it has been explicitly asked for" ):
508508 """
509509 Force the ORM to install a module.
510510
@@ -549,6 +549,14 @@ def force_install_module(cr, module, if_installed=None):
549549 states = dict (cr .fetchall ())
550550 toinstall = [m for m in states if states [m ] == "to install" ]
551551
552+ if module in toinstall :
553+ _logger .info (
554+ "force install of module %r (and its dependencies) because %s%s" ,
555+ module ,
556+ reason ,
557+ " and modules {!r} are already installed" .format (if_installed ) if if_installed else "" ,
558+ )
559+
552560 # auto_install modules...
553561 if AUTO_INSTALL in ("all" , "only_link_modules" ) and toinstall :
554562 # Same algo as ir.module.module.button_install(): https://git.io/fhCKd
@@ -607,8 +615,11 @@ def force_install_module(cr, module, if_installed=None):
607615 [toinstall , list (INSTALLED_MODULE_STATES )],
608616 )
609617 for (mod ,) in cr .fetchall ():
610- _logger .debug ("auto install module %r due to module %r being force installed" , mod , module )
611- force_install_module (cr , mod )
618+ force_install_module (
619+ cr ,
620+ mod ,
621+ reason = "it is an auto install module and its dependency {!r} has been force installed" .format (module ),
622+ )
612623
613624 # TODO handle module exclusions
614625
@@ -648,7 +659,7 @@ def new_module_dep(cr, module, new_dep):
648659 if mod_state in INSTALLED_MODULE_STATES :
649660 # Module was installed, need to install all its deps, recursively,
650661 # to make sure the new dep is installed
651- force_install_module (cr , module )
662+ force_install_module (cr , new_dep , reason = "it's a new dependency of {!r}" . format ( module ) )
652663
653664
654665def remove_module_deps (cr , module , old_deps ):
@@ -755,7 +766,7 @@ def trigger_auto_install(cr, module):
755766
756767 cr .execute (query , [module , INSTALLED_MODULE_STATES ])
757768 if cr .rowcount :
758- force_install_module (cr , module )
769+ force_install_module (cr , module , reason = "it's an auto install module and all its dependencies are installed" )
759770 return True
760771 return False
761772
0 commit comments