[IMP] __openerp__.py can now contain maitainer and contribors

bzr revid: chs@openerp.com-20100516162741-5qwvadhq07bdt1be
This commit is contained in:
Christophe Simonis 2010-05-16 18:27:41 +02:00
parent 04a13826a0
commit 2f3c27b631
5 changed files with 50 additions and 55 deletions

View File

@ -3,6 +3,7 @@
# #
# OpenERP, Open Source Management Solution # OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -716,14 +717,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, **kwargs):
for kind in ('init', 'update'): for kind in ('init', 'update'):
if package.state=='to upgrade': if package.state=='to upgrade':
# upgrading the module information # upgrading the module information
modobj.write(cr, 1, [mid], { modobj.write(cr, 1, [mid], modobj.get_values_from_terp(package.data))
'description': package.data.get('description', ''),
'shortdesc': package.data.get('name', ''),
'author': package.data.get('author', 'Unknown'),
'website': package.data.get('website', ''),
'license': package.data.get('license', 'GPL-2'),
'certificate': package.data.get('certificate') or None,
})
load_init_update_xml(cr, m, idref, mode, kind) load_init_update_xml(cr, m, idref, mode, kind)
load_data(cr, m, idref, mode) load_data(cr, m, idref, mode)
if hasattr(package, 'demo') or (package.dbdemo and package.state != 'installed'): if hasattr(package, 'demo') or (package.dbdemo and package.state != 'installed'):

View File

@ -3,6 +3,7 @@
# #
# OpenERP, Open Source Management Solution # OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -25,7 +26,8 @@
'version': '1.2', 'version': '1.2',
'category': 'Generic Modules/Base', 'category': 'Generic Modules/Base',
'description': """The kernel of OpenERP, needed for all installation.""", 'description': """The kernel of OpenERP, needed for all installation.""",
'author': 'Tiny', 'author': 'OpenERP s.a.',
'maintainer': 'OpenERP s.a.',
'website': 'http://www.openerp.com', 'website': 'http://www.openerp.com',
'depends': [], 'depends': [],
'init_xml': [ 'init_xml': [

View File

@ -3,6 +3,7 @@
# #
# OpenERP, Open Source Management Solution # OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -123,6 +124,8 @@ class module(osv.osv):
'shortdesc': fields.char('Short Description', size=256, readonly=True, translate=True), 'shortdesc': fields.char('Short Description', size=256, readonly=True, translate=True),
'description': fields.text("Description", readonly=True, translate=True), 'description': fields.text("Description", readonly=True, translate=True),
'author': fields.char("Author", size=128, readonly=True), 'author': fields.char("Author", size=128, readonly=True),
'maintainer': fields.char('Maintainer', size=128, readonly=True),
'contributors': fields.text('Contributors', readonly=True),
'website': fields.char("Website", size=256, readonly=True), 'website': fields.char("Website", size=256, readonly=True),
# attention: Incorrect field names !! # attention: Incorrect field names !!
@ -306,6 +309,19 @@ class module(osv.osv):
self.update_translations(cr, uid, ids) self.update_translations(cr, uid, ids)
return True return True
@staticmethod
def get_values_from_terp(terp):
return {
'description': terp.get('description', ''),
'shortdesc': terp.get('name', ''),
'author': terp.get('author', 'Unknown'),
'maintainer': terp.get('maintainer', False),
'contributors': ', '.join(terp.get('contributors', [])),
'website': terp.get('website', ''),
'license': terp.get('license', 'GPL-2'),
'certificate': terp.get('certificate') or None,
}
# update the list of available packages # update the list of available packages
def update_list(self, cr, uid, context={}): def update_list(self, cr, uid, context={}):
res = [0, 0] # [update, add] res = [0, 0] # [update, add]
@ -313,46 +329,31 @@ class module(osv.osv):
# iterate through installed modules and mark them as being so # iterate through installed modules and mark them as being so
for mod_name in addons.get_modules(): for mod_name in addons.get_modules():
ids = self.search(cr, uid, [('name','=',mod_name)]) ids = self.search(cr, uid, [('name','=',mod_name)])
terp = self.get_module_info(mod_name)
values = self.get_values_from_terp(terp)
if ids: if ids:
id = ids[0] id = ids[0]
mod = self.browse(cr, uid, id) mod = self.browse(cr, uid, id)
terp = self.get_module_info(mod_name)
if terp.get('installable', True) and mod.state == 'uninstallable': if terp.get('installable', True) and mod.state == 'uninstallable':
self.write(cr, uid, id, {'state': 'uninstalled'}) self.write(cr, uid, id, {'state': 'uninstalled'})
if parse_version(terp.get('version', '')) > parse_version(mod.latest_version or ''): if parse_version(terp.get('version', '')) > parse_version(mod.latest_version or ''):
self.write(cr, uid, id, { 'url': ''}) self.write(cr, uid, id, { 'url': ''})
res[0] += 1 res[0] += 1
self.write(cr, uid, id, { self.write(cr, uid, id, values)
'description': terp.get('description', ''),
'shortdesc': terp.get('name', ''),
'author': terp.get('author', 'Unknown'),
'website': terp.get('website', ''),
'license': terp.get('license', 'GPL-2'),
'certificate': terp.get('certificate') or None,
})
cr.execute('DELETE FROM ir_module_module_dependency WHERE module_id = %s', (id,)) cr.execute('DELETE FROM ir_module_module_dependency WHERE module_id = %s', (id,))
self._update_dependencies(cr, uid, ids[0], terp.get('depends', [])) else:
self._update_category(cr, uid, ids[0], terp.get('category', 'Uncategorized')) mod_path = addons.get_module_path(mod_name)
continue if not mod_path:
mod_path = addons.get_module_path(mod_name) continue
if mod_path:
terp = self.get_module_info(mod_name)
if not terp or not terp.get('installable', True): if not terp or not terp.get('installable', True):
continue continue
id = self.create(cr, uid, { id = self.create(cr, uid, dict(name=mod_name, state='uninstalled', **values))
'name': mod_name,
'state': 'uninstalled',
'description': terp.get('description', ''),
'shortdesc': terp.get('name', ''),
'author': terp.get('author', 'Unknown'),
'website': terp.get('website', ''),
'license': terp.get('license', 'GPL-2'),
'certificate': terp.get('certificate') or None,
})
res[1] += 1 res[1] += 1
self._update_dependencies(cr, uid, id, terp.get('depends', [])) self._update_dependencies(cr, uid, id, terp.get('depends', []))
self._update_category(cr, uid, id, terp.get('category', 'Uncategorized')) self._update_category(cr, uid, id, terp.get('category', 'Uncategorized'))
return res return res
@ -379,14 +380,7 @@ class module(osv.osv):
except Exception, e: except Exception, e:
raise orm.except_orm(_('Error'), _('Can not create the module file:\n %s') % (fname,)) raise orm.except_orm(_('Error'), _('Can not create the module file:\n %s') % (fname,))
terp = self.get_module_info(mod.name) terp = self.get_module_info(mod.name)
self.write(cr, uid, mod.id, { self.write(cr, uid, mod.id, self.get_values_from_terp(terp))
'description': terp.get('description', ''),
'shortdesc': terp.get('name', ''),
'author': terp.get('author', 'Unknown'),
'website': terp.get('website', ''),
'license': terp.get('license', 'GPL-2'),
'certificate': terp.get('certificate') or None,
})
cr.execute('DELETE FROM ir_module_module_dependency ' \ cr.execute('DELETE FROM ir_module_module_dependency ' \
'WHERE module_id = %s', (mod.id,)) 'WHERE module_id = %s', (mod.id,))
self._update_dependencies(cr, uid, mod.id, terp.get('depends', self._update_dependencies(cr, uid, mod.id, terp.get('depends',

View File

@ -95,10 +95,16 @@
<field colspan="4" name="description" select="2"/> <field colspan="4" name="description" select="2"/>
<field name="installed_version"/> <field name="installed_version"/>
<field name="latest_version"/> <field name="latest_version"/>
<field name="author" select="2"/> <group colspan='2' col='2'>
<field name="website" select="2" widget="url"/> <field name="author" select="2"/>
<field name="url" widget="url"/> <field name='maintainer'/>
<field name="published_version"/> <field name='contributors'/>
</group>
<group colspan='2' col='2'>
<field name="website" select="2" widget="url"/>
<field name="url" widget="url"/>
<field name="published_version"/>
</group>
<field name="license"/> <field name="license"/>
<field name="demo" readonly="1"/> <field name="demo" readonly="1"/>
<newline/> <newline/>
@ -141,6 +147,8 @@
<field name="name"/> <field name="name"/>
<field name="shortdesc"/> <field name="shortdesc"/>
<field name="author"/> <field name="author"/>
<field name='maintainer'/>
<field name='contributors'/>
<field name="installed_version"/> <field name="installed_version"/>
<field name="latest_version"/> <field name="latest_version"/>
<field name="published_version"/> <field name="published_version"/>

View File

@ -3,6 +3,7 @@
# #
# OpenERP, Open Source Management Solution # OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -56,7 +57,7 @@ class wizard_install_module(wizard.interface):
terp = mod_obj.get_module_info(module) terp = mod_obj.get_module_info(module)
if not terp.get('installable', True): if not terp.get('installable', True):
continue continue
# XXX check if this code is correct... # XXX check if this code is correct...
fm = imp.find_module(module) fm = imp.find_module(module)
try: try:
@ -65,12 +66,8 @@ class wizard_install_module(wizard.interface):
if fm[0]: if fm[0]:
fm[0].close() fm[0].close()
mod_id = mod_obj.create(cr, uid, { values = mod_obj.get_values_from_terp(terp)
'name': module, mod_id = mod_obj.create(cr, uid, dict(name=module, state='uninstalled', **values))
'state': 'uninstalled',
'description': terp.get('description', ''),
'shortdesc': terp.get('name', ''),
'author': terp.get('author', 'Unknown')})
dependencies = terp.get('depends', []) dependencies = terp.get('depends', [])
for d in dependencies: for d in dependencies:
cr.execute('insert into ir_module_module_dependency (module_id,name) values (%s, %s)', (mod_id, d)) cr.execute('insert into ir_module_module_dependency (module_id,name) values (%s, %s)', (mod_id, d))