[IMP]: Improvement in module install/uninstall/upgrade so after this updates we will have a better dialog box to see the changes applied

bzr revid: rpa@tinyerp.com-20110318123852-vzifr66nmq3tk4tl
This commit is contained in:
Rucha (Open ERP) 2011-03-18 18:08:52 +05:30
parent 0c6da1259c
commit 2a718069d6
4 changed files with 49 additions and 50 deletions

View File

@ -354,7 +354,7 @@
</record>
<record id="config_wizard_simple_view" model="ir.actions.todo">
<field name="action_id" ref="action_config_simple_view_form"/>
<field name="restart">always</field>
<field name="restart">never</field>
<field name="sequence">1</field>
</record>
</data>

View File

@ -286,7 +286,7 @@ class module(osv.osv):
demo = demo or mdemo
return demo
def upgrade(self, cr, uid, ids, context=None):
def apply_upgrade(self, cr, uid, ids, mode='install', context=None):
mod_obj = self.pool.get('ir.module.module')
ids = mod_obj.search(cr, uid, [('state', 'in', ['to upgrade', 'to remove', 'to install'])])
unmet_packages = []
@ -303,7 +303,11 @@ class module(osv.osv):
_db, pool = pooler.restart_pool(cr.dbname, update_module=True)
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'base', 'view_base_module_upgrade_install')
if ids:
view_name = 'view_base_module_upgrade_install'
else:
view_name = 'view_base_module_upgrade'
id2 = data_obj._get_id(cr, uid, 'base', view_name)
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
return {
@ -315,11 +319,12 @@ class module(osv.osv):
'type': 'ir.actions.act_window',
'target': 'new',
'nodestroy':True,
'context': {'modules': ids, 'mode': mode}
}
def button_install(self, cr, uid, ids, context=None):
self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context)
res = self.upgrade(cr, uid, ids, context=context)
res = self.apply_upgrade(cr, uid, ids, mode='install', context=context)
return res
@ -342,8 +347,7 @@ class module(osv.osv):
raise orm.except_orm(_('Error'), _('Some installed modules depend on the module you plan to Uninstall :\n %s') % '\n'.join(map(lambda x: '\t%s: %s' % (x[0], x[1]), res)))
self.write(cr, uid, ids, {'state': 'to remove'})
self.upgrade(cr, uid, ids, context=context)
return True
return self.apply_upgrade(cr, uid, ids, mode='uninstall', context=context)
def button_uninstall_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'installed'})
@ -368,7 +372,7 @@ class module(osv.osv):
if dep.state == 'installed':
ids2 = self.search(cr, uid, [('name','=',dep.name)])
to_install.extend(ids2)
res = self.upgrade(cr, uid, ids, context=context)
res = self.apply_upgrade(cr, uid, ids, mode='upgrade', context=context)
return res
def button_upgrade_cancel(self, cr, uid, ids, context=None):

View File

@ -32,39 +32,6 @@ class base_module_upgrade(osv.osv_memory):
'module_info': fields.text('Modules to update',readonly=True),
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
""" Changes the view dynamically
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return: New arch of view.
"""
res = super(base_module_upgrade, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
record_id = context and context.get('active_id', False) or False
active_model = context.get('active_model')
if (not record_id) or (not active_model):
return res
ids = self.get_module_list(cr, uid, context=context)
if not ids:
res['arch'] = '''<form string="Apply Scheduled Upgrades">
<separator string="System update completed" colspan="4"/>
<label align="0.0" string="The selected modules have been updated / installed !" colspan="4"/>
<label align="0.0" string="We suggest to reload the menu tab to see the new menus (Ctrl+T then Ctrl+R)." colspan="4"/>
<separator string="" colspan="4"/>
<newline/>
<button special="cancel" string="Close" icon="gtk-cancel"/>
<button name="config" string="Start configuration" type="object" icon="gtk-ok"/>
</form>'''
return res
def get_module_list(self, cr, uid, context=None):
mod_obj = self.pool.get('ir.module.module')
ids = mod_obj.search(cr, uid, [
('state', 'in', ['to upgrade', 'to remove', 'to install'])])
return ids
def default_get(self, cr, uid, fields, context=None):
"""
@ -76,9 +43,15 @@ class base_module_upgrade(osv.osv_memory):
@param context: A standard dictionary for contextual values
"""
mod_obj = self.pool.get('ir.module.module')
ids = self.get_module_list(cr, uid, context=context)
res = mod_obj.read(cr, uid, ids, ['name','state'], context)
return {'module_info': '\n'.join(map(lambda x: x['name']+' : '+x['state'], res))}
ids = context.get('modules', [])
mode = context.get('mode', 'install')
mode_string = {
'install': 'Installed',
'upgrade': 'Upgraded',
'uninstall': 'Uninstalled'
}
res = mod_obj.read(cr, uid, ids, ['name'], context)
return {'module_info': '\n'.join(map(lambda x: x['name']+' : '+ mode_string[mode], res))}
def config(self, cr, uid, ids, context=None):

View File

@ -36,18 +36,40 @@
<field name="type">form</field>
<field name="priority" eval="20"/>
<field name="arch" type="xml">
<form string="Apply Scheduled Upgrades">
<separator string="System update completed" colspan="4"/>
<label align="0.0" string="The selected modules have been updated / installed !" colspan="4"/>
<label align="0.0" string="We suggest to reload the menu tab to see the new menus (Ctrl+T then Ctrl+R)." colspan="4"/>
<separator string="" colspan="4"/>
<form string="System update message">
<separator string="System update completed" colspan="4"/>
<label align="0.0" string="Update Processed. Please note that if you were installing a module with dependencies on uninstalled modules, those module have been installed too." colspan="4"/>
<label align="0.0" string="You'll find hereunder the list of modifications done in your database." colspan="4"/>
<field name="module_info" nolabel="1" colspan="4"/>
<label align="0.0" string="We suggest you to reload the menu tab to see the new menus (Ctrl+T then Ctrl+R)." colspan="4"/>
<separator string="" colspan="4"/>
<newline/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="config" string="Start configuration" type="object" icon="gtk-ok"/>
<label string=""/>
<button special="cancel" string="_Ok" icon="gtk-ok"/>
</form>
</field>
</record>
<record id="view_base_module_upgrade" model="ir.ui.view">
<field name="name">Module Upgrade Install</field>
<field name="model">base.module.upgrade</field>
<field name="type">form</field>
<field name="priority" eval="20"/>
<field name="arch" type="xml">
<form string="System update message">
<separator string="System update completed" colspan="4"/>
<label align="0.0" string="Update Processed. Please note that if you were installing a module with dependencies on uninstalled modules, those module have been installed too." colspan="4"/>
<label align="0.0" string="You'll find hereunder the list of modifications done in your database." colspan="4"/>
<label align="0.0" string="We suggest you to reload the menu tab to see the new menus (Ctrl+T then Ctrl+R)." colspan="4"/>
<separator string="" colspan="4"/>
<newline/>
<label string=""/>
<button special="cancel" string="_Ok" icon="gtk-ok"/>
</form>
</field>
</record>
<!-- Check if its really used somewhere or not -->
<record id="action_view_base_module_upgrade_install" model="ir.actions.act_window">
<field name="name">Module Upgrade Install</field>
<field name="type">ir.actions.act_window</field>