diff options
| author | Jean-Baptiste Aubort <jean-baptiste.aubort@camptocamp.com> | 2008-08-22 16:46:26 +0200 |
|---|---|---|
| committer | Jean-Baptiste Aubort <jean-baptiste.aubort@camptocamp.com> | 2008-08-22 16:46:26 +0200 |
| commit | ed2c0e73c0168d3afad4f0b075586f0077239fb8 (patch) | |
| tree | dd61f36972bc5666eb587e55854ff09745aa4618 /bin/addons/base/module | |
| parent | 69c7cdbe767b85569b1584bd424ca88b4e9557f2 (diff) | |
| parent | 4f935d09cdfd7207dd3ae6415a6109ea4be1647a (diff) | |
merge trunk #1015
bzr revid: jean-baptiste.aubort@camptocamp.com-20080822144626-kblv6krdoo4pema2
Diffstat (limited to 'bin/addons/base/module')
| -rw-r--r-- | bin/addons/base/module/module.py | 36 | ||||
| -rw-r--r-- | bin/addons/base/module/module_view.xml | 7 | ||||
| -rw-r--r-- | bin/addons/base/module/module_wizard.xml | 2 | ||||
| -rw-r--r-- | bin/addons/base/module/wizard/wizard_export_lang.py | 81 | ||||
| -rw-r--r-- | bin/addons/base/module/wizard/wizard_module_upgrade.py | 9 |
5 files changed, 32 insertions, 103 deletions
diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py index 548d2c65f10..4772ccbfbf6 100644 --- a/bin/addons/base/module/module.py +++ b/bin/addons/base/module/module.py @@ -266,42 +266,28 @@ class module(osv.osv): raise orm.except_orm(_('Error'), _('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 diff --git a/bin/addons/base/module/module_view.xml b/bin/addons/base/module/module_view.xml index 1aef6ddc923..5b14c59e9f0 100644 --- a/bin/addons/base/module/module_view.xml +++ b/bin/addons/base/module/module_view.xml @@ -79,15 +79,12 @@ <newline/> <field name="state" readonly="1" select="1"/> <group col="6" colspan="2"> - <button name="button_install" states="uninstalled" string="Install" type="object"/> + <button name="button_install" states="uninstalled" string="Schedule for Installation" type="object"/> <button name="button_install_cancel" states="to install" string="Cancel Install" type="object"/> <button name="button_uninstall" states="installed" string="Uninstall (beta)" type="object"/> <button name="button_uninstall_cancel" states="to remove" string="Cancel Uninstall" type="object"/> - <button name="button_upgrade" states="installed" string="Upgrade" type="object"/> + <button name="button_upgrade" states="installed" string="Schedule Upgrade" type="object"/> <button name="button_upgrade_cancel" states="to upgrade" string="Cancel Upgrade" type="object"/> - <!-- - <button string="Update translations" name="button_update_translations" type="object" states="installed"/> - --> </group> </page> <page string="Dependencies"> diff --git a/bin/addons/base/module/module_wizard.xml b/bin/addons/base/module/module_wizard.xml index e6a445e3a86..aee1b2c8d5d 100644 --- a/bin/addons/base/module/module_wizard.xml +++ b/bin/addons/base/module/module_wizard.xml @@ -13,7 +13,7 @@ </record> <menuitem action="wizard_update" icon="STOCK_CONVERT" id="menu_module_update" parent="base.menu_management" type="wizard"/> - <wizard id="wizard_upgrade" model="ir.module.module" name="module.upgrade" string="Apply upgrades"/> + <wizard id="wizard_upgrade" model="ir.module.module" name="module.upgrade" string="Apply Scheduled Upgrades"/> <menuitem action="wizard_upgrade" id="menu_wizard_upgrade" parent="base.menu_management" type="wizard"/> <record id="wizard_lang_install" model="ir.actions.wizard"> diff --git a/bin/addons/base/module/wizard/wizard_export_lang.py b/bin/addons/base/module/wizard/wizard_export_lang.py index f5df07532df..dc288707577 100644 --- a/bin/addons/base/module/wizard/wizard_export_lang.py +++ b/bin/addons/base/module/wizard/wizard_export_lang.py @@ -37,81 +37,14 @@ import pooler from osv import fields,osv -''' -view_form_init="""<?xml version="1.0"?> -<form string="Export language"> - <image name="gtk-dialog-info" colspan="2"/> - <group colspan="2" col="4"> - <separator string="Export translation file" colspan="4"/> - <label align="0.0" string="Choose a language to export:" colspan="4"/> - <field name="lang" colspan="4"/> - </group> -</form>""" - -view_form_finish="""<?xml version="1.0"?> -<form string="Export language"> - <image name="gtk-dialog-info" colspan="2"/> - <group colspan="2" col="4"> - <separator string="Export done" colspan="4"/> - <field name="data" readonly="1" colspan="3"/> - <label align="0.0" string="Save this document to a .CSV file and open it with\n your favourite spreadsheet software. The file\n encoding is UTF-8. You have to translate the latest\n column before reimporting it." colspan="4"/> - </group> -</form>""" - -class wizard_export_lang(wizard.interface): - def _get_language(self, cr, uid, context): - lang_obj=pooler.get_pool(cr.dbname).get('res.lang') - ids=lang_obj.search(cr, uid, [('active', '=', True),]) - langs=lang_obj.browse(cr, uid, ids) - return [(lang.code, lang.translatable and lang.name or _('New language')) for lang in langs] - - def _get_file(self, cr, uid, data, context): - file=tools.trans_generate(data['form']['lang'], 'all', dbname=cr.dbname) - buf=StringIO.StringIO() - writer=csv.writer(buf, 'UNIX') - for row in file: - writer.writerow(row) - del file - out=base64.encodestring(buf.getvalue()) - buf.close() - return {'data': out} - - fields_form={ - 'lang': {'string':'Language', 'type':'selection', 'selection':_get_language,}, - } - fields_form_finish={ - 'data': {'string':'File', 'type':'binary', 'readonly': True,}, - } - states={ - 'init':{ - 'actions': [], - 'result': {'type': 'form', 'arch': view_form_init, 'fields': fields_form, - 'state': [ - ('end', 'Cancel', 'gtk-cancel'), - ('finish', 'Ok', 'gtk-ok', True) - ] - } - }, - 'finish':{ - 'actions': [_get_file], - 'result': {'type': 'form', 'arch': view_form_finish, - 'fields': fields_form_finish, - 'state': [ - ('end', 'Close', 'gtk-cancel', True) - ] - } - }, - } -wizard_export_lang('module.lang.export') -''' class wizard_export_lang(osv.osv_memory): def _get_languages(self, cr, uid, context): lang_obj=pooler.get_pool(cr.dbname).get('res.lang') - ids=lang_obj.search(cr, uid, [('active', '=', True),]) + ids=lang_obj.search(cr, uid, ['&', ('active', '=', True), ('translatable', '=', True),]) langs=lang_obj.browse(cr, uid, ids) - return [(lang.code, lang.translatable and lang.name or _('New language')) for lang in langs] + return [('', _('New language'))] + [(lang.code, lang.name) for lang in langs] def act_cancel(self, cr, uid, ids, context=None): @@ -132,7 +65,11 @@ class wizard_export_lang(osv.osv_memory): if this.format == 'csv': this.advice = _("Save this document to a .CSV file and open it with your favourite spreadsheet software. The file encoding is UTF-8. You have to translate the latest column before reimporting it.") elif this.format == 'po': - this.advice = _("Save this document to a .po file and edit it with a specific software or a text editor. The file encoding is UTF-8.") + ext = this.lang and '.po' or '.pot' + this.advice = _("Save this document to a %s file and edit it with a specific software or a text editor. The file encoding is UTF-8." % (ext,)) + elif this.format == 'tgz': + ext = this.lang and '.po' or '.pot' + this.advice = _('Save this document to a .tgz file. This archive containt UTF-8 %s files and may be uploaded to launchpad.' % (ext,)) out=base64.encodestring(buf.getvalue()) buf.close() @@ -140,8 +77,8 @@ class wizard_export_lang(osv.osv_memory): _name = "wizard.module.lang.export" _columns = { - 'lang': fields.selection(_get_languages, 'Language',required=True), - 'format': fields.selection( ( ('csv','CSV File'), ('po','PO File') ), 'File Format', required=True), + 'lang': fields.selection(_get_languages, 'Language'), # not required: unset = new language + 'format': fields.selection( ( ('csv','CSV File'), ('po','PO File'), ('tgz', 'TGZ Archive')), 'File Format', required=True), 'modules': fields.many2many('ir.module.module', 'rel_modules_langexport', 'wiz_id', 'module_id', 'Modules', domain=[('state','=','installed')]), 'data': fields.binary('File', readonly=True), 'advice': fields.text('', readonly=True), diff --git a/bin/addons/base/module/wizard/wizard_module_upgrade.py b/bin/addons/base/module/wizard/wizard_module_upgrade.py index c9cf6042108..55432bd44f9 100644 --- a/bin/addons/base/module/wizard/wizard_module_upgrade.py +++ b/bin/addons/base/module/wizard/wizard_module_upgrade.py @@ -89,6 +89,15 @@ class wizard_info_get(wizard.interface): mod_obj = pool.get('ir.module.module') ids = mod_obj.search(cr, uid, [ ('state', 'in', ['to upgrade', 'to remove', 'to install'])]) + unmet_packages=[] + mod_dep_obj = pool.get('ir.module.module.dependency') + for mod in mod_obj.browse(cr,uid,ids): + depends_mod_ids=mod_dep_obj.search(cr,uid,[('module_id','=',mod.id)]) + for dep_mod in mod_dep_obj.browse(cr,uid,depends_mod_ids): + if dep_mod.state in ('unknown','uninstalled'): + unmet_packages.append(dep_mod.name) + if len(unmet_packages): + raise wizard.except_wizard('Unmet dependency !','Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages)) mod_obj.download(cr, uid, ids, context=context) cr.commit() db, pool = pooler.restart_pool(cr.dbname, update_module=True) |
