Browse Source

[MIG][module_auto_update] Backport from v10

pull/918/head
Jairo Llopis 8 years ago
parent
commit
f4305bc884
  1. 3
      module_auto_update/README.rst
  2. 2
      module_auto_update/__openerp__.py
  3. 2
      module_auto_update/hooks.py
  4. 36
      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
  8. 1
      requirements.txt

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
: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 <brent.hughes@laslabs.com>
* 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.

2
module_auto_update/__manifest__.py → 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, '

2
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):

36
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):

10
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',

8
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()

4
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()

1
requirements.txt

@ -1,3 +1,4 @@
checksumdir
python-ldap
unidecode
acme_tiny

Loading…
Cancel
Save