diff --git a/module_auto_update/__openerp__.py b/module_auto_update/__openerp__.py index 5bd2fc850..2621fb525 100644 --- a/module_auto_update/__openerp__.py +++ b/module_auto_update/__openerp__.py @@ -5,7 +5,7 @@ { 'name': 'Module Auto Update', 'summary': 'Automatically update Odoo modules', - 'version': '9.0.1.0.1', + 'version': '9.0.1.0.2', 'category': 'Extra Tools', 'website': 'https://odoo-community.org/', 'author': 'LasLabs, ' diff --git a/module_auto_update/wizards/module_upgrade.py b/module_auto_update/wizards/module_upgrade.py index a9b577e3d..3499a9961 100644 --- a/module_auto_update/wizards/module_upgrade.py +++ b/module_auto_update/wizards/module_upgrade.py @@ -10,6 +10,7 @@ class ModuleUpgrade(models.TransientModel): @api.model def get_module_list(self): + """Set modules to upgrade searching by their dir checksum.""" Module = self.env["ir.module.module"] installed_modules = Module.search([('state', '=', 'installed')]) upgradeable_modules = installed_modules.filtered( @@ -18,28 +19,33 @@ class ModuleUpgrade(models.TransientModel): upgradeable_modules.button_upgrade() return super(ModuleUpgrade, self).get_module_list() - @api.multi - def upgrade_module_cancel(self): - return super( - ModuleUpgrade, - self.with_context(retain_checksum_installed=True), - ).upgrade_module_cancel() - @api.multi def upgrade_module(self): + """Make a fully automated addon upgrade.""" # Compute updates by checksum when called in @api.model fashion if not self: self.get_module_list() - # Get base adddon status before updating - base = self.env["ir.module.module"].search([("name", "=", "base")]) - pre_state = base.state + Module = self.env["ir.module.module"] + # Get every addon state before updating + pre_states = {addon["name"]: addon["state"] + for addon in Module.search_read([], ["name", "state"])} + # Perform upgrades, possibly in a limited graph that excludes me + self.env.cr.autocommit(True) # Avoid transaction lock result = super(ModuleUpgrade, self).upgrade_module() - # Update base addon checksum if its state changed - base.invalidate_cache() - if base.state != pre_state: - # This triggers the write hook that should have been triggered - # when the module was [un]installed/updated in the base-only - # module graph inside above call to super(), and updates its - # dir checksum as needed - base.latest_version = base.latest_version + self.env.cr.autocommit(False) + # Reload environments, anything may have changed + self.env.clear() + # Update addons checksum if state changed and I wasn't uninstalled + own = Module.search_read( + [("name", "=", "module_auto_update")], + ["state"], + limit=1) + if own and own[0]["state"] != "uninstalled": + for addon in Module.search([]): + if addon.state != pre_states.get(addon.name): + # Trigger the write hook that should have been + # triggered when the module was [un]installed/updated in + # the limited module graph inside above call to super(), + # and updates its dir checksum as needed + addon.latest_version = addon.latest_version return result