[FIX] automatically adapt version numbers of modules
bzr revid: chs@openerp.com-20120824142323-m503lc6tfj4vntop
This commit is contained in:
parent
ca4c2b8c49
commit
9f9de9914a
|
@ -116,7 +116,6 @@ class module(osv.osv):
|
|||
info = {}
|
||||
try:
|
||||
info = modules.load_information_from_description_file(name)
|
||||
info['version'] = release.major_version + '.' + info['version']
|
||||
except Exception:
|
||||
_logger.debug('Error when trying to fetch informations for '
|
||||
'module %s', name, exc_info=True)
|
||||
|
@ -132,9 +131,10 @@ class module(osv.osv):
|
|||
return res
|
||||
|
||||
def _get_latest_version(self, cr, uid, ids, field_name=None, arg=None, context=None):
|
||||
res = dict.fromkeys(ids, '')
|
||||
default_version = modules.adapt_version('1.0')
|
||||
res = dict.fromkeys(ids, default_version)
|
||||
for m in self.browse(cr, uid, ids):
|
||||
res[m.id] = self.get_module_info(m.name).get('version', '')
|
||||
res[m.id] = self.get_module_info(m.name).get('version', default_version)
|
||||
return res
|
||||
|
||||
def _get_views(self, cr, uid, ids, field_name=None, arg=None, context=None):
|
||||
|
@ -546,8 +546,9 @@ class module(osv.osv):
|
|||
|
||||
# update the list of available packages
|
||||
def update_list(self, cr, uid, context=None):
|
||||
res = [0, 0] # [update, add]
|
||||
res = [0, 0] # [update, add]
|
||||
|
||||
default_version = modules.adapt_version('1.0')
|
||||
known_mods = self.browse(cr, uid, self.search(cr, uid, []))
|
||||
known_mods_names = dict([(m.name, m) for m in known_mods])
|
||||
|
||||
|
@ -566,7 +567,7 @@ class module(osv.osv):
|
|||
updated_values[key] = values[key]
|
||||
if terp.get('installable', True) and mod.state == 'uninstallable':
|
||||
updated_values['state'] = 'uninstalled'
|
||||
if parse_version(terp.get('version', '')) > parse_version(mod.latest_version or ''):
|
||||
if parse_version(terp.get('version', default_version)) > parse_version(mod.latest_version or default_version):
|
||||
res[0] += 1
|
||||
if updated_values:
|
||||
self.write(cr, uid, mod.id, updated_values)
|
||||
|
@ -587,14 +588,15 @@ class module(osv.osv):
|
|||
|
||||
def download(self, cr, uid, ids, download=True, context=None):
|
||||
res = []
|
||||
default_version = modules.adapt_version('1.0')
|
||||
for mod in self.browse(cr, uid, ids, context=context):
|
||||
if not mod.url:
|
||||
continue
|
||||
match = re.search('-([a-zA-Z0-9\._-]+)(\.zip)', mod.url, re.I)
|
||||
version = '0'
|
||||
version = default_version
|
||||
if match:
|
||||
version = match.group(1)
|
||||
if parse_version(mod.installed_version or '0') >= parse_version(version):
|
||||
if parse_version(mod.installed_version) >= parse_version(version):
|
||||
continue
|
||||
res.append(mod.url)
|
||||
if not download:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
# Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
|
||||
# Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
|
@ -32,7 +32,8 @@ from openerp.modules.module import \
|
|||
load_information_from_description_file, \
|
||||
get_module_resource, zip_directory, \
|
||||
get_module_path, initialize_sys_path, \
|
||||
load_openerp_module, init_module_models
|
||||
load_openerp_module, init_module_models, \
|
||||
adapt_version
|
||||
|
||||
from openerp.modules.loading import load_modules
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
# Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
|
||||
# Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
|
@ -337,7 +337,7 @@ def load_information_from_description_file(module):
|
|||
'license': 'AGPL-3',
|
||||
'name': False,
|
||||
'post_load': None,
|
||||
'version': '0.0.0',
|
||||
'version': '1.0',
|
||||
'web': False,
|
||||
'website': '',
|
||||
'sequence': 100,
|
||||
|
@ -357,6 +357,7 @@ def load_information_from_description_file(module):
|
|||
# 'active' has been renamed 'auto_install'
|
||||
info['auto_install'] = info['active']
|
||||
|
||||
info['version'] = adapt_version(info['version'])
|
||||
return info
|
||||
|
||||
#TODO: refactor the logger in this file to follow the logging guidelines
|
||||
|
@ -454,15 +455,22 @@ def get_modules():
|
|||
|
||||
def get_modules_with_version():
|
||||
modules = get_modules()
|
||||
res = {}
|
||||
res = dict.fromkeys(modules, adapt_version('1.0'))
|
||||
for module in modules:
|
||||
try:
|
||||
info = load_information_from_description_file(module)
|
||||
res[module] = "%s.%s" % (release.major_version, info['version'])
|
||||
except Exception, e:
|
||||
res[module] = info['version']
|
||||
except Exception:
|
||||
continue
|
||||
return res
|
||||
|
||||
def adapt_version(version):
|
||||
serie = release.major_version
|
||||
if version == serie or not version.startswith(serie + '.'):
|
||||
version = '%s.%s' % (serie, version)
|
||||
return version
|
||||
|
||||
|
||||
def get_test_modules(module, submodule, explode):
|
||||
"""
|
||||
Return a list of submodules containing tests.
|
||||
|
|
Loading…
Reference in New Issue