diff options
| author | Xavier Morel <xmo@odoo.com> | 2019-07-25 12:10:18 +0000 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2019-07-25 12:10:18 +0000 |
| commit | fce64e7d94a40333a6c2eb369ee5a94f9bd987c3 (patch) | |
| tree | 36d41571f3b575ffca83e48f3601b020f362b0d1 /odoo/modules/db.py | |
| parent | f9e6c76168467d46eab377304e74d13b124dda27 (diff) | |
[FIX] core: auto_install modules being very sticky
An unintended side-effect of #29431 is apparently that auto_install
applications automatically get reinstalled when uninstalled, which was
not the goal.
Move the auto_install selection back into db.py, this version seems to
work even though the previous attempt was apparently unsuccessful.
closes odoo/odoo#35180
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'odoo/modules/db.py')
| -rw-r--r-- | odoo/modules/db.py | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/odoo/modules/db.py b/odoo/modules/db.py index 3a432f0fecb..e37317288ae 100644 --- a/odoo/modules/db.py +++ b/odoo/modules/db.py @@ -75,12 +75,33 @@ def initialize(cr): # Install recursively all auto-installing modules while True: - cr.execute("""SELECT m.name FROM ir_module_module m WHERE m.auto_install AND state != 'to install' - AND NOT EXISTS ( - SELECT 1 FROM ir_module_module_dependency d JOIN ir_module_module mdep ON (d.name = mdep.name) - WHERE d.module_id = m.id AND mdep.state != 'to install' - )""") + # this selects all the auto_install modules whose auto_install_required + # deps are marked as to install + cr.execute(""" + SELECT m.name FROM ir_module_module m + WHERE m.auto_install + AND state != 'to install' + AND NOT EXISTS ( + SELECT 1 FROM ir_module_module_dependency d + JOIN ir_module_module mdep ON (d.name = mdep.name) + WHERE d.module_id = m.id + AND d.auto_install_required + AND mdep.state != 'to install' + )""") to_auto_install = [x[0] for x in cr.fetchall()] + # however if the module has non-required deps we need to install + # those, so merge-in the modules which have a dependen*t* which is + # *either* to_install or in to_auto_install and merge it in? + cr.execute(""" + SELECT d.name FROM ir_module_module_dependency d + JOIN ir_module_module m ON (d.module_id = m.id) + JOIN ir_module_module mdep ON (d.name = mdep.name) + WHERE (m.state = 'to install' OR m.name = any(%s)) + -- don't re-mark marked modules + AND NOT (mdep.state = 'to install' OR mdep.name = any(%s)) + """, [to_auto_install, to_auto_install]) + to_auto_install.extend(x[0] for x in cr.fetchall()) + if not to_auto_install: break cr.execute("""UPDATE ir_module_module SET state='to install' WHERE name in %s""", (tuple(to_auto_install),)) |
