Browse Source

[MIG][module_auto_update] Backport from v10

pull/1198/head
Jairo Llopis 7 years ago
committed by Stéphane Bidoul (ACSONE)
parent
commit
719cb6314b
No known key found for this signature in database GPG Key ID: BCAB2555446B5B92
  1. 3
      module_auto_update/README.rst
  2. 2
      module_auto_update/__openerp__.py
  3. 2
      module_auto_update/hooks.py
  4. 26
      module_auto_update/models/module.py
  5. 10
      module_auto_update/tests/test_module.py
  6. 8
      module_auto_update/tests/test_module_upgrade.py
  7. 4
      module_auto_update/wizards/module_upgrade.py

3
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 .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :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 Bug Tracker
=========== ===========
@ -57,6 +57,7 @@ Contributors
* Brent Hughes <brent.hughes@laslabs.com> * Brent Hughes <brent.hughes@laslabs.com>
* Juan José Scarafía <jjs@adhoc.com.ar> * Juan José Scarafía <jjs@adhoc.com.ar>
* Jairo Llopis <jairo.llopis@tecnativa.com>
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.

2
module_auto_update/__manifest__.py → module_auto_update/__openerp__.py

@ -5,7 +5,7 @@
{ {
'name': 'Module Auto Update', 'name': 'Module Auto Update',
'summary': 'Automatically update Odoo modules', 'summary': 'Automatically update Odoo modules',
'version': '10.0.1.0.0',
'version': '9.0.1.0.0',
'category': 'Extra Tools', 'category': 'Extra Tools',
'website': 'https://odoo-community.org/', 'website': 'https://odoo-community.org/',
'author': 'LasLabs, ' 'author': 'LasLabs, '

2
module_auto_update/hooks.py

@ -2,7 +2,7 @@
# Copyright 2017 LasLabs Inc. # Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). # 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): def post_init_hook(cr, registry):

26
module_auto_update/models/module.py

@ -4,8 +4,8 @@
import logging 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__) _logger = logging.getLogger(__name__)
try: try:
@ -30,11 +30,15 @@ class Module(models.Model):
).split(",") ).split(",")
for r in self: for r in self:
try:
r.checksum_dir = dirhash( r.checksum_dir = dirhash(
get_module_path(r.name), get_module_path(r.name),
'sha1', 'sha1',
excluded_extensions=exclude, excluded_extensions=exclude,
) )
except TypeError:
# Module path not found
pass
def _store_checksum_installed(self, vals): def _store_checksum_installed(self, vals):
if self.env.context.get('retain_checksum_installed'): if self.env.context.get('retain_checksum_installed'):
@ -48,17 +52,19 @@ class Module(models.Model):
@api.multi @api.multi
def button_uninstall_cancel(self): 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 @api.multi
def button_upgrade_cancel(self): 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 @api.model
def create(self, vals): def create(self, vals):

10
module_auto_update/tests/test_module.py

@ -7,8 +7,8 @@ import tempfile
import mock 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 from .. import post_init_hook
@ -18,7 +18,7 @@ try:
except ImportError: except ImportError:
_logger.debug('Cannot `import checksumdir`.') _logger.debug('Cannot `import checksumdir`.')
model = 'odoo.addons.module_auto_update.models.module'
model = 'openerp.addons.module_auto_update.models.module'
class TestModule(TransactionCase): class TestModule(TransactionCase):
@ -170,9 +170,11 @@ class TestModule(TransactionCase):
'List update does not mark upgradeable modules "to upgrade"', '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 """It should not change the state of a module with a former state
other than 'installed' to 'to upgrade'""" other than 'installed' to 'to upgrade'"""
get_module_path_mock.return_value = self.own_dir_path
vals = { vals = {
'name': 'module_auto_update_test_module', 'name': 'module_auto_update_test_module',
'state': 'uninstalled', 'state': 'uninstalled',

8
module_auto_update/tests/test_module_upgrade.py

@ -4,9 +4,9 @@
import mock 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): class TestModuleUpgrade(TransactionCase):
@ -29,7 +29,7 @@ class TestModuleUpgrade(TransactionCase):
'Upgrade cancellation does not preserve checksum_installed', 'Upgrade cancellation does not preserve checksum_installed',
) )
@mock.patch.object(Registry, 'new')
@mock.patch.object(RegistryManager, 'new')
def test_upgrade_module(self, new_mock): def test_upgrade_module(self, new_mock):
"""It should call update_list method on ir.module.module""" """It should call update_list method on ir.module.module"""
update_list_mock = mock.MagicMock() update_list_mock = mock.MagicMock()

4
module_auto_update/wizards/module_upgrade.py

@ -2,7 +2,7 @@
# Copyright 2017 LasLabs Inc. # Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). # 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): class ModuleUpgrade(models.TransientModel):
@ -18,4 +18,4 @@ class ModuleUpgrade(models.TransientModel):
@api.multi @api.multi
def upgrade_module(self): def upgrade_module(self):
self.env['ir.module.module'].update_list() self.env['ir.module.module'].update_list()
super(ModuleUpgrade, self).upgrade_module()
return super(ModuleUpgrade, self).upgrade_module()
Loading…
Cancel
Save