[FIX] ir.module.module: Incorrect field names !!
* installed_version refer the latest version (the one on disk) * latest_version refer the installed version (the one in database) * published_version refer the version available on the repository bzr revid: christophe@tinyerp.com-20081211114413-olfcmv4g650o350f
This commit is contained in:
parent
c0152f5fcf
commit
765ef60221
|
@ -380,7 +380,7 @@ class MigrationManager(object):
|
|||
|
||||
from tools.parse_version import parse_version
|
||||
|
||||
parsed_installed_version = parse_version(pkg.latest_version)
|
||||
parsed_installed_version = parse_version(pkg.installed_version)
|
||||
current_version = parse_version(convert_version(pkg.data.get('version', '0')))
|
||||
|
||||
versions = _get_migration_versions(pkg)
|
||||
|
@ -402,7 +402,7 @@ class MigrationManager(object):
|
|||
try:
|
||||
mod = imp.load_source(name, pyfile, fp)
|
||||
logger.notifyChannel('migration', netsvc.LOG_INFO, 'addon %(addon)s: Running migration %(version)s %(name)s"' % mergedict({'name': mod.__name__},strfmt))
|
||||
mod.migrate(self.cr, pkg.latest_version)
|
||||
mod.migrate(self.cr, pkg.installed_version)
|
||||
except ImportError:
|
||||
logger.notifyChannel('migration', netsvc.LOG_ERROR, 'addon %(addon)s: Unable to load %(stage)-migration file %(file)s' % mergedict({'file': opj(modulename,pyfile)}, strfmt))
|
||||
raise
|
||||
|
@ -427,13 +427,14 @@ def load_module_graph(cr, graph, status=None, check_access_rules=True, **kwargs)
|
|||
|
||||
# update the graph with values from the database (if exist)
|
||||
## First, we set the default values for each package in graph
|
||||
additional_data = dict.fromkeys([p.name for p in graph], {'id': 0, 'state': 'uninstalled', 'dbdemo': False, 'latest_version': None})
|
||||
additional_data = dict.fromkeys([p.name for p in graph], {'id': 0, 'state': 'uninstalled', 'dbdemo': False, 'installed_version': None})
|
||||
## Then we get the values from the database
|
||||
cr.execute('SELECT name, id, state, demo AS dbdemo, latest_version'
|
||||
cr.execute('SELECT name, id, state, demo AS dbdemo, latest_version AS installed_version'
|
||||
' FROM ir_module_module'
|
||||
' WHERE name in (%s)' % (','.join(['%s'] * len(graph))),
|
||||
additional_data.keys()
|
||||
)
|
||||
|
||||
## and we update the default values with values from the database
|
||||
additional_data.update(dict([(x.pop('name'), x) for x in cr.dictfetchall()]))
|
||||
|
||||
|
@ -491,6 +492,7 @@ def load_module_graph(cr, graph, status=None, check_access_rules=True, **kwargs)
|
|||
cr.execute('update ir_module_module set demo=%s where id=%s', (True, mid))
|
||||
package_todo.append(package.name)
|
||||
ver = release.major_version + '.' + package.data.get('version', '1.0')
|
||||
# update the installed version in database...
|
||||
cr.execute("update ir_module_module set state='installed', latest_version=%s where id=%s", (ver, mid,))
|
||||
cr.commit()
|
||||
|
||||
|
|
|
@ -98,13 +98,10 @@ class module(osv.osv):
|
|||
return {}
|
||||
return info
|
||||
|
||||
def _get_installed_version(self, cr, uid, ids, field_name=None, arg=None, context={}):
|
||||
res = {}
|
||||
def _get_latest_version(self, cr, uid, ids, field_name=None, arg=None, context={}):
|
||||
res = dict.setdefault(ids, '')
|
||||
for m in self.browse(cr, uid, ids):
|
||||
if m.state in ('installed', 'to upgrade', 'to remove'):
|
||||
res[m.id] = self.get_module_info(m.name).get('version', '')
|
||||
else:
|
||||
res[m.id] = ''
|
||||
res[m.id] = self.get_module_info(m.name).get('version', '')
|
||||
return res
|
||||
|
||||
def _get_views(self, cr, uid, ids, field_name=None, arg=None, context={}):
|
||||
|
@ -143,10 +140,16 @@ class module(osv.osv):
|
|||
'description': fields.text("Description", readonly=True, translate=True),
|
||||
'author': fields.char("Author", size=128, readonly=True),
|
||||
'website': fields.char("Website", size=256, readonly=True),
|
||||
'installed_version': fields.function(_get_installed_version, method=True,
|
||||
string='Installed version', type='char'),
|
||||
'latest_version': fields.char('Latest version', size=64, readonly=True),
|
||||
|
||||
# attention: Incorrect field names !!
|
||||
# installed_version refer the latest version (the one on disk)
|
||||
# latest_version refer the installed version (the one in database)
|
||||
# published_version refer the version available on the repository
|
||||
'installed_version': fields.function(_get_latest_version, method=True,
|
||||
string='Latest version', type='char'),
|
||||
'latest_version': fields.char('Installed version', size=64, readonly=True),
|
||||
'published_version': fields.char('Published Version', size=64, readonly=True),
|
||||
|
||||
'url': fields.char('URL', size=128),
|
||||
'dependencies_id': fields.one2many('ir.module.module.dependency',
|
||||
'module_id', 'Dependencies', readonly=True),
|
||||
|
@ -289,7 +292,6 @@ class module(osv.osv):
|
|||
self.write(cr, uid, id, {'state': 'uninstalled'})
|
||||
if parse_version(terp.get('version', '')) > parse_version(mod.latest_version or ''):
|
||||
self.write(cr, uid, id, {
|
||||
'latest_version': terp.get('version'),
|
||||
'url': ''})
|
||||
res[0] += 1
|
||||
self.write(cr, uid, id, {
|
||||
|
@ -328,7 +330,6 @@ class module(osv.osv):
|
|||
'shortdesc': terp.get('name', ''),
|
||||
'author': terp.get('author', 'Unknown'),
|
||||
'website': terp.get('website', ''),
|
||||
'latest_version': terp.get('version', ''),
|
||||
'license': terp.get('license', 'GPL-2'),
|
||||
})
|
||||
res[1] += 1
|
||||
|
@ -365,7 +366,6 @@ class module(osv.osv):
|
|||
if not ids:
|
||||
self.create(cr, uid, {
|
||||
'name': name,
|
||||
'latest_version': version,
|
||||
'published_version': version,
|
||||
'url': url,
|
||||
'state': 'uninstalled',
|
||||
|
@ -373,16 +373,15 @@ class module(osv.osv):
|
|||
res[1] += 1
|
||||
else:
|
||||
id = ids[0]
|
||||
latest_version = self.read(cr, uid, id, ['latest_version'])\
|
||||
['latest_version']
|
||||
if latest_version == 'x': # 'x' version was a mistake
|
||||
latest_version = '0'
|
||||
if parse_version(version) > parse_version(latest_version):
|
||||
self.write(cr, uid, id,
|
||||
{'latest_version': version, 'url': url})
|
||||
installed_version = self.read(cr, uid, id, ['latest_version'])['latest_version']
|
||||
if installed_version == 'x': # 'x' version was a mistake
|
||||
installed_version = '0'
|
||||
if parse_version(version) > parse_version(installed_version):
|
||||
self.write(cr, uid, id, {
|
||||
'url': url
|
||||
})
|
||||
res[0] += 1
|
||||
published_version = self.read(cr, uid, id, ['published_version'])\
|
||||
['published_version']
|
||||
published_version = self.read(cr, uid, id, ['published_version'])['published_version']
|
||||
if published_version == 'x' or not published_version:
|
||||
published_version = '0'
|
||||
if parse_version(version) > parse_version(published_version):
|
||||
|
|
|
@ -97,11 +97,10 @@ def init_db(cr):
|
|||
cr.execute('select nextval(\'ir_module_module_id_seq\')')
|
||||
id = cr.fetchone()[0]
|
||||
cr.execute('insert into ir_module_module \
|
||||
(id, author, latest_version, website, name, shortdesc, description, \
|
||||
(id, author, website, name, shortdesc, description, \
|
||||
category_id, state) \
|
||||
values (%s, %s, %s, %s, %s, %s, %s, %s, %s)', (
|
||||
values (%s, %s, %s, %s, %s, %s, %s, %s)', (
|
||||
id, info.get('author', ''),
|
||||
release.major_version + '.' + info.get('version', ''),
|
||||
info.get('website', ''), i, info.get('name', False),
|
||||
info.get('description', ''), p_id, state))
|
||||
dependencies = info.get('depends', [])
|
||||
|
|
Loading…
Reference in New Issue