[ADD] API for immediate installation of modules (modules kanban view), buttons everywhere, remove weird kanban image fallback

bzr revid: xmo@openerp.com-20111209114002-dlz79hxft05bhnqx
This commit is contained in:
Xavier Morel 2011-12-09 12:40:02 +01:00
parent 926041c8b8
commit 89eb114091
2 changed files with 17 additions and 8 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>