diff --git a/module_auto_update/README.rst b/module_auto_update/README.rst index 3535f4fb2..4a6a4c4cd 100644 --- a/module_auto_update/README.rst +++ b/module_auto_update/README.rst @@ -34,7 +34,7 @@ To perform upgrades manually, click the "Apply Scheduled Upgrades" menu item in .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/149/10.0 + :target: https://runbot.odoo-community.org/runbot/149/9.0 Bug Tracker =========== @@ -57,6 +57,7 @@ Contributors * Brent Hughes * Juan José Scarafía +* Jairo Llopis Do not contact contributors directly about support or help with technical issues. diff --git a/module_auto_update/__manifest__.py b/module_auto_update/__openerp__.py similarity index 96% rename from module_auto_update/__manifest__.py rename to module_auto_update/__openerp__.py index db65d269a..1cbd4d0be 100644 --- a/module_auto_update/__manifest__.py +++ b/module_auto_update/__openerp__.py @@ -5,7 +5,7 @@ { 'name': 'Module Auto Update', 'summary': 'Automatically update Odoo modules', - 'version': '10.0.1.0.0', + 'version': '9.0.1.0.0', 'category': 'Extra Tools', 'website': 'https://odoo-community.org/', 'author': 'LasLabs, ' diff --git a/module_auto_update/hooks.py b/module_auto_update/hooks.py index f062966c3..5a05d0d23 100644 --- a/module_auto_update/hooks.py +++ b/module_auto_update/hooks.py @@ -2,7 +2,7 @@ # Copyright 2017 LasLabs Inc. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -from odoo import SUPERUSER_ID, api +from openerp import SUPERUSER_ID, api def post_init_hook(cr, registry): diff --git a/module_auto_update/models/module.py b/module_auto_update/models/module.py index 4d9ccec59..22c608ab9 100644 --- a/module_auto_update/models/module.py +++ b/module_auto_update/models/module.py @@ -4,8 +4,8 @@ import logging -from odoo import api, fields, models -from odoo.modules.module import get_module_path +from openerp import api, fields, models +from openerp.modules.module import get_module_path _logger = logging.getLogger(__name__) try: @@ -30,11 +30,15 @@ class Module(models.Model): ).split(",") for r in self: - r.checksum_dir = dirhash( - get_module_path(r.name), - 'sha1', - excluded_extensions=exclude, - ) + try: + r.checksum_dir = dirhash( + get_module_path(r.name), + 'sha1', + excluded_extensions=exclude, + ) + except TypeError: + # Module path not found + pass def _store_checksum_installed(self, vals): if self.env.context.get('retain_checksum_installed'): @@ -48,17 +52,19 @@ class Module(models.Model): @api.multi def button_uninstall_cancel(self): - return super( - Module, - self.with_context(retain_checksum_installed=True), - ).button_uninstall_cancel() + # TODO Use super() like in v10 after pull is merged + # HACK https://github.com/odoo/odoo/pull/18597 + return self.with_context(retain_checksum_installed=True).write({ + 'state': 'installed', + }) @api.multi def button_upgrade_cancel(self): - return super( - Module, - self.with_context(retain_checksum_installed=True), - ).button_upgrade_cancel() + # TODO Use super() like in v10 after pull is merged + # HACK https://github.com/odoo/odoo/pull/18597 + return self.with_context(retain_checksum_installed=True).write({ + 'state': 'installed', + }) @api.model def create(self, vals): diff --git a/module_auto_update/tests/test_module.py b/module_auto_update/tests/test_module.py index 5d499fc27..36b22090c 100644 --- a/module_auto_update/tests/test_module.py +++ b/module_auto_update/tests/test_module.py @@ -7,8 +7,8 @@ import tempfile import mock -from odoo.modules import get_module_path -from odoo.tests.common import TransactionCase +from openerp.modules import get_module_path +from openerp.tests.common import TransactionCase from .. import post_init_hook @@ -18,7 +18,7 @@ try: except ImportError: _logger.debug('Cannot `import checksumdir`.') -model = 'odoo.addons.module_auto_update.models.module' +model = 'openerp.addons.module_auto_update.models.module' class TestModule(TransactionCase): @@ -170,9 +170,11 @@ class TestModule(TransactionCase): 'List update does not mark upgradeable modules "to upgrade"', ) - def test_update_list_only_changes_installed(self): + @mock.patch('%s.get_module_path' % model) + def test_update_list_only_changes_installed(self, get_module_path_mock): """It should not change the state of a module with a former state other than 'installed' to 'to upgrade'""" + get_module_path_mock.return_value = self.own_dir_path vals = { 'name': 'module_auto_update_test_module', 'state': 'uninstalled', diff --git a/module_auto_update/tests/test_module_upgrade.py b/module_auto_update/tests/test_module_upgrade.py index edc24fd8e..52134dd17 100644 --- a/module_auto_update/tests/test_module_upgrade.py +++ b/module_auto_update/tests/test_module_upgrade.py @@ -4,9 +4,9 @@ import mock -from odoo.modules import get_module_path -from odoo.modules.registry import Registry -from odoo.tests.common import TransactionCase +from openerp.modules import get_module_path +from openerp.modules.registry import RegistryManager +from openerp.tests.common import TransactionCase class TestModuleUpgrade(TransactionCase): @@ -29,7 +29,7 @@ class TestModuleUpgrade(TransactionCase): 'Upgrade cancellation does not preserve checksum_installed', ) - @mock.patch.object(Registry, 'new') + @mock.patch.object(RegistryManager, 'new') def test_upgrade_module(self, new_mock): """It should call update_list method on ir.module.module""" update_list_mock = mock.MagicMock() diff --git a/module_auto_update/wizards/module_upgrade.py b/module_auto_update/wizards/module_upgrade.py index e9b69e07c..0abf8dfca 100644 --- a/module_auto_update/wizards/module_upgrade.py +++ b/module_auto_update/wizards/module_upgrade.py @@ -2,7 +2,7 @@ # Copyright 2017 LasLabs Inc. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -from odoo import api, models +from openerp import api, models class ModuleUpgrade(models.TransientModel): @@ -18,4 +18,4 @@ class ModuleUpgrade(models.TransientModel): @api.multi def upgrade_module(self): self.env['ir.module.module'].update_list() - super(ModuleUpgrade, self).upgrade_module() + return super(ModuleUpgrade, self).upgrade_module() diff --git a/requirements.txt b/requirements.txt index 6cad5a6f1..9343b1181 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +checksumdir python-ldap unidecode acme_tiny