[IMP] module views

* Improve experience when installing a module from kanban view (remove useless steps)
* Improve icons management

Also make code handling module descriptor files clearer and simpler

bzr revid: xmo@openerp.com-20111209122948-6zv8z7pw5hd40dyk
This commit is contained in:
Xavier Morel 2011-12-09 13:29:48 +01:00
commit 95e0099102
4 changed files with 48 additions and 39 deletions

View File

@ -321,7 +321,19 @@ class module(osv.osv):
def button_install(self, cr, uid, ids, context=None):
self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context)
return dict(ACTION_DICT, name=_('Install'))
def button_immediate_install(self, cr, uid, ids, context=None):
""" Installs the selected module(s) immediately and fully,
returns the next res.config action to execute
:param ids: identifiers of the modules to install
:returns: next res.config item to execute
:rtype: dict[str, object]
"""
self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context)
cr.commit()
db, pool = pooler.restart_pool(cr.dbname, update_module=True)
return pool.get('res.config').next(db.cursor(), uid, [], context=context)
def button_install_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'uninstalled', 'demo':False})

View File

@ -70,8 +70,9 @@
<field name="complexity"/>
<templates>
<t t-name="kanban-box">
<t t-set="installed" t-value="record.state.raw_value == 'installed'"/>
<a type="edit">
<img t-attf-src="/#{record.name.value}/static/images/icon.png" class="oe_module_icon"/>
<img t-attf-src="#{record.icon.value}" class="oe_module_icon"/>
</a>
<div class="oe_module_desc">
<h4><a type="edit"><field name="shortdesc"/></a></h4>
@ -79,13 +80,9 @@
<field name="category_id"/><br/>
<span t-if="record.complexity.raw_value == 'Expert'" class="oe_label oe_warning">Complex</span>
</p>
<a type="object" name="button_install" states="uninstalled" class="button">Install</a>
<button t-if="record.state.raw_value == 'installed'" class="label" disabled="disabled">Installed</button>
<button type="object" name="button_immediate_install" states="uninstalled" class="button">Install</button>
<button t-if="installed" class="label" disabled="disabled">Installed</button>
</div>
<script>
$('.oe_module_icon').error(function() { $(this).attr('src', "/base/static/src/img/kanban_partner.png"); });
$('a .oe_module_icon').error(function() { $(this).attr('src', "/base/static/src/img/kanban_partner.png"); });
</script>
</t>
</templates>
</kanban>

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -218,6 +218,11 @@ def get_module_resource(module, *args):
return resource_path
return False
def get_module_icon(module):
iconpath = ['static', 'src', 'img', 'icon.png']
if get_module_resource(module, *iconpath):
return ('/' + module + '/') + '/'.join(iconpath)
return '/base/' + '/'.join(iconpath)
def load_information_from_description_file(module):
"""
@ -231,37 +236,32 @@ def load_information_from_description_file(module):
if terp_file:
info = {}
if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path+'.zip'):
terp_f = tools.file_open(terp_file)
try:
info = eval(terp_f.read())
except Exception:
logger.notifyChannel('modules', netsvc.LOG_ERROR,
'module %s: exception while evaluating file %s' %
(module, terp_file))
raise
finally:
terp_f.close()
# TODO the version should probably be mandatory
info.setdefault('version', '0')
info.setdefault('category', 'Uncategorized')
info.setdefault('depends', [])
info.setdefault('author', '')
info.setdefault('website', '')
info.setdefault('name', False)
info.setdefault('description', '')
info.setdefault('complexity', 'normal')
info.setdefault('application', False)
info.setdefault('icon', 'images/icon.png')
info['certificate'] = info.get('certificate') or None
info['web'] = info.get('web') or False
info['license'] = info.get('license') or 'AGPL-3'
info.setdefault('installable', True)
info.setdefault('active', False)
# If the following is provided, it is called after the module is --loaded.
info.setdefault('post_load', None)
for kind in ['data', 'demo', 'test',
'init_xml', 'update_xml', 'demo_xml']:
info.setdefault(kind, [])
# default values for descriptor
info = {
'active': False,
'application': False,
'author': '',
'category': 'Uncategorized',
'certificate': None,
'complexity': 'normal',
'depends': [],
'description': '',
'icon': get_module_icon(module),
'installable': True,
'license': 'AGPL-3',
'name': False,
'post_load': None,
'version': '0.0.0',
'web': False,
'website': '',
}
info.update(itertools.izip(
'depends data demo test init_xml update_xml demo_xml'.split(),
iter(list, None)))
with tools.file_open(terp_file) as terp_f:
info.update(eval(terp_f.read()))
return info
#TODO: refactor the logger in this file to follow the logging guidelines