[REF]: ir.module: Improvement in code, return common dictionary

bzr revid: rpa@tinyerp.com-20110704133431-iq309mmduwjlrxde
This commit is contained in:
Rucha (Open ERP) 2011-07-04 19:04:31 +05:30
parent d1cf666594
commit 3df3c54572
1 changed files with 14 additions and 28 deletions

View File

@ -40,6 +40,16 @@ from tools.translate import _
from osv import fields, osv, orm
ACTION_DICT = {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'base.module.upgrade',
'target': 'new',
'type': 'ir.actions.act_window',
'nodestroy':True,
}
class module_category(osv.osv):
_name = "ir.module.category"
_description = "Module Category"
@ -286,15 +296,7 @@ class module(osv.osv):
def button_install(self, cr, uid, ids, context=None):
self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context)
return {
'name': _('Install'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'base.module.upgrade',
'target': 'new',
'type': 'ir.actions.act_window',
'nodestroy':True,
}
return dict(ACTION_DICT, name=_('Install'))
def button_install_cancel(self, cr, uid, ids, context=None):
@ -315,15 +317,7 @@ class module(osv.osv):
if res:
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'})
return {
'name': _('Uninstall'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'base.module.upgrade',
'target': 'new',
'type': 'ir.actions.act_window',
'nodestroy':True,
}
return dict(ACTION_DICT, name=_('Uninstall'))
def button_uninstall_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'installed'})
@ -360,20 +354,12 @@ class module(osv.osv):
to_install.extend(ids2)
self.button_install(cr, uid, to_install, context=context)
return {
'name': _('Upgrade'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'base.module.upgrade',
'target': 'new',
'type': 'ir.actions.act_window',
'nodestroy':True,
}
# return True
return dict(ACTION_DICT, name=_('Upgrade'))
def button_upgrade_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'installed'})
return True
def button_update_translations(self, cr, uid, ids, context=None):
self.update_translations(cr, uid, ids)
return True