diff options
| author | Christophe Simonis <christophe@tinyerp.com> | 2008-08-20 14:00:54 +0200 |
|---|---|---|
| committer | Christophe Simonis <christophe@tinyerp.com> | 2008-08-20 14:00:54 +0200 |
| commit | 75da15c3b9cea38c8415abc7f2ee450a4c1f6d86 (patch) | |
| tree | 3e561f90c10901a5db440f472c5310121b2f3525 /bin/addons/base/module/module.py | |
| parent | 17f0040aae5e26cb132f4a7db08eb532d28f8dc2 (diff) | |
modules:
* merge methods state_change and state_upgrade into state_update
* raise an exception when there is an unmet dependency
bzr revid: christophe@tinyerp.com-20080820120054-1l2fdexs1lty7nk8
Diffstat (limited to 'bin/addons/base/module/module.py')
| -rw-r--r-- | bin/addons/base/module/module.py | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py index 548d2c65f10..f64c5503991 100644 --- a/bin/addons/base/module/module.py +++ b/bin/addons/base/module/module.py @@ -267,41 +267,27 @@ class module(osv.osv): _('You try to remove a module that is installed or will be installed')) return super(module, self).unlink(cr, uid, ids, context=context) - def state_change(self, cr, uid, ids, newstate, context={}, level=50): + def state_update(self, cr, uid, ids, newstate, states_to_update, context={}, level=50): if level<1: - raise Exception, _('Recursion error in modules dependencies !') + raise orm.except_orm(_('Error'), _('Recursion error in modules dependencies !')) demo = True for module in self.browse(cr, uid, ids): mdemo = True for dep in module.dependencies_id: - ids2 = self.search(cr, uid, [('name','=',dep.name)]) - mdemo = self.state_change(cr, uid, ids2, newstate, context, level-1,)\ - and mdemo + if dep.state == 'unknown': + raise orm.except_orm(_('Error'), _('Unmet dependency: %s') % (dep.name,)) + if dep.state != newstate: + ids2 = self.search(cr, uid, [('name','=',dep.name)]) + mdemo = self.state_update(cr, uid, ids2, newstate, states_to_update, context, level-1,) and mdemo if not module.dependencies_id: mdemo = module.demo - if module.state == 'uninstalled': + if module.state in states_to_update: self.write(cr, uid, [module.id], {'state': newstate, 'demo':mdemo}) demo = demo and mdemo return demo - def state_upgrade(self, cr, uid, ids, newstate, context=None, level=50): - dep_obj = self.pool.get('ir.module.module.dependency') - if level<1: - raise Exception, _('Recursion error in modules dependencies !') - for module in self.browse(cr, uid, ids): - dep_ids = dep_obj.search(cr, uid, [('name', '=', module.name)]) - if dep_ids: - ids2 = [] - for dep in dep_obj.browse(cr, uid, dep_ids): - if dep.module_id.state != 'to upgrade': - ids2.append(dep.module_id.id) - self.state_upgrade(cr, uid, ids2, newstate, context, level) - if module.state == 'installed': - self.write(cr, uid, module.id, {'state': newstate}) - return True - def button_install(self, cr, uid, ids, context={}): - return self.state_change(cr, uid, ids, 'to install', context) + return self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context) def button_install_cancel(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state': 'uninstalled', 'demo':False}) @@ -327,7 +313,7 @@ class module(osv.osv): self.write(cr, uid, ids, {'state': 'installed'}) return True def button_upgrade(self, cr, uid, ids, context=None): - return self.state_upgrade(cr, uid, ids, 'to upgrade', context) + return self.state_update(cr, uid, ids, 'to upgrade', ['installed'], context) def button_upgrade_cancel(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state': 'installed'}) return True |
