diff options
| author | Numerigraphe - Lionel Sausin <ls@numerigraphe.fr> | 2010-11-12 15:10:41 +0100 |
|---|---|---|
| committer | Numerigraphe - Lionel Sausin <ls@numerigraphe.fr> | 2010-11-12 15:10:41 +0100 |
| commit | 182cf2b196da0d1f55ddfdcff62058b423e1bbc0 (patch) | |
| tree | 779b50e2e54b1624ba669b4a3f56bb6407c08d49 /bin/addons/base/module | |
| parent | e013734045bbaae906748a8026455bac6786568e (diff) | |
| parent | cc0d270bab0d0b7862430c3e527f7edc02d1d587 (diff) | |
[MERGE] sync with the trunk
bzr revid: ls@numerigraphe.fr-20101112141041-19kpvr7pzxqankqo
Diffstat (limited to 'bin/addons/base/module')
31 files changed, 1126 insertions, 1015 deletions
diff --git a/bin/addons/base/module/__init__.py b/bin/addons/base/module/__init__.py index 93f0f0a3d1c..1b7abf2e76e 100644 --- a/bin/addons/base/module/__init__.py +++ b/bin/addons/base/module/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # @@ -15,14 +15,10 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## -import module_web import module import wizard import report - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py index 89a059eb9c5..81985332157 100644 --- a/bin/addons/base/module/module.py +++ b/bin/addons/base/module/module.py @@ -19,27 +19,24 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## - -import tarfile -import re -import urllib -import os import imp import logging -import tools -from osv import fields, osv, orm -import zipfile -import release +import os +import re +import urllib import zipimport -import wizard import addons -import pooler import netsvc +import pooler +import release +import tools from tools.parse_version import parse_version from tools.translate import _ +from osv import fields, osv, orm + class module_category(osv.osv): _name = "ir.module.category" _description = "Module Category" @@ -56,8 +53,8 @@ class module_category(osv.osv): result = dict(cr.fetchall()) for id in ids: cr.execute('select id from ir_module_category where parent_id=%s', (id,)) - childs = [c for c, in cr.fetchall()] - result[id] = reduce(lambda x,y:x+y, [result.get(c, 0) for c in childs], result.get(id, 0)) + result[id] = sum([result.get(c, 0) for (c,) in cr.fetchall()], + result.get(id, 0)) return result _columns = { @@ -72,6 +69,7 @@ module_category() class module(osv.osv): _name = "ir.module.module" _description = "Module" + __logger = logging.getLogger('base.' + _name) def get_module_info(self, name): info = {} @@ -79,8 +77,9 @@ class module(osv.osv): info = addons.load_information_from_description_file(name) if 'version' in info: info['version'] = release.major_version + '.' + info['version'] - except: - pass + except Exception: + self.__logger.debug('Error when trying to fetch informations for ' + 'module %s', name, exc_info=True) return info def _get_latest_version(self, cr, uid, ids, field_name=None, arg=None, context={}): @@ -115,23 +114,27 @@ class module(osv.osv): v = view_obj.browse(cr,uid,data_id.res_id) aa = v.inherit_id and '* INHERIT ' or '' res[mnames[data_id.module]]['views_by_module'] += aa + v.name + ' ('+v.type+')\n' - except: - pass + except Exception: + self.__logger.debug( + 'Unknown error while browsing ir.ui.view[%s]', + data_id.res_id, exc_info=True) elif key=='ir.actions.report.xml': res[mnames[data_id.module]]['reports_by_module'] += report_obj.browse(cr,uid,data_id.res_id).name + '\n' elif key=='ir.ui.menu': try: m = menu_obj.browse(cr,uid,data_id.res_id) res[mnames[data_id.module]]['menus_by_module'] += m.complete_name + '\n' - except: - pass - except KeyError, e: + except Exception: + self.__logger.debug( + 'Unknown error while browsing ir.ui.menu[%s]', + data_id.res_id, exc_info=True) + except KeyError: pass return res _columns = { - 'name': fields.char("Name", size=128, readonly=True, required=True), - 'category_id': fields.many2one('ir.module.category', 'Category', readonly=True), + 'name': fields.char("Name", size=128, readonly=True, required=True, select=True), + 'category_id': fields.many2one('ir.module.category', 'Category', readonly=True, select=True), 'shortdesc': fields.char('Short Description', size=256, readonly=True, translate=True), 'description': fields.text("Description", readonly=True, translate=True), 'author': fields.char("Author", size=128, readonly=True), @@ -151,8 +154,6 @@ class module(osv.osv): 'url': fields.char('URL', size=128, readonly=True), 'dependencies_id': fields.one2many('ir.module.module.dependency', 'module_id', 'Dependencies', readonly=True), - 'web_dependencies_id': fields.one2many('ir.module.web.dependency', - 'module_id', 'Web Dependencies', readonly=True), 'state': fields.selection([ ('uninstallable','Not Installable'), ('uninstalled','Not Installed'), @@ -160,7 +161,7 @@ class module(osv.osv): ('to upgrade','To be upgraded'), ('to remove','To be removed'), ('to install','To be installed') - ], string='State', readonly=True), + ], string='State', readonly=True, select=True), 'demo': fields.boolean('Demo data'), 'license': fields.selection([ ('GPL-2', 'GPL Version 2'), @@ -175,12 +176,14 @@ class module(osv.osv): 'reports_by_module': fields.function(_get_views, method=True, string='Reports', type='text', multi="meta", store=True), 'views_by_module': fields.function(_get_views, method=True, string='Views', type='text', multi="meta", store=True), 'certificate' : fields.char('Quality Certificate', size=64, readonly=True), + 'web': fields.boolean('Has a web component', readonly=True), } _defaults = { 'state': lambda *a: 'uninstalled', 'demo': lambda *a: False, 'license': lambda *a: 'AGPL-3', + 'web': False, } _order = 'name' @@ -229,7 +232,7 @@ class module(osv.osv): raise Exception('Unable to find %r in path' % (binary,)) - def state_update(self, cr, uid, ids, newstate, states_to_update, context={}, level=100): + def state_update(self, cr, uid, ids, newstate, states_to_update, context=None, level=100): if level<1: raise orm.except_orm(_('Error'), _('Recursion error in modules dependencies !')) demo = False @@ -237,25 +240,25 @@ class module(osv.osv): mdemo = False for dep in module.dependencies_id: if dep.state == 'unknown': - raise orm.except_orm(_('Error'), _("You try to install the module '%s' that depends on the module:'%s'.\nBut this module is not available in your system.") % (module.name, dep.name,)) + raise orm.except_orm(_('Error'), _("You try to install module '%s' that depends on module '%s'.\nBut the latter module is not available in your system.") % (module.name, dep.name,)) ids2 = self.search(cr, uid, [('name','=',dep.name)]) if dep.state != newstate: mdemo = self.state_update(cr, uid, ids2, newstate, states_to_update, context, level-1,) or mdemo else: od = self.browse(cr, uid, ids2)[0] mdemo = od.demo or mdemo - - for web_mod in module.web_dependencies_id: - if web_mod.state == 'unknown': - raise orm.except_orm(_('Error'), _("You try to install the module '%s' that depends on the module:'%s'.\nBut this module is not available in your system.") % (module.name, dep.name,)) - ids2 = self.pool.get('ir.module.web').search(cr, uid, [('module','=',web_mod.name)]) - self.pool.get('ir.module.web').button_install(cr, uid, ids2) - + terp = self.get_module_info(module.name) try: self._check_external_dependencies(terp) except Exception, e: - raise orm.except_orm(_('Error'), _('Unable %s the module "%s" because an external dependencie is not met: %s' % (newstate, module.name, e.args[0]))) + if newstate == 'to install': + msg = _('Unable to install module "%s" because an external dependency is not met: %s') + elif newstate == 'to upgrade': + msg = _('Unable to upgrade module "%s" because an external dependency is not met: %s') + else: + msg = _('Unable to process module "%s" because an external dependency is not met: %s') + raise orm.except_orm(_('Error'), msg % (module.name, e.args[0])) if not module.dependencies_id: mdemo = module.demo if module.state in states_to_update: @@ -340,6 +343,7 @@ class module(osv.osv): 'website': terp.get('website', ''), 'license': terp.get('license', 'GPL-2'), 'certificate': terp.get('certificate') or None, + 'web': terp.get('web') or False, } # update the list of available packages @@ -373,7 +377,6 @@ class module(osv.osv): id = self.create(cr, uid, dict(name=mod_name, state='uninstalled', **values)) res[1] += 1 self._update_dependencies(cr, uid, id, terp.get('depends', [])) - self._update_web_dependencies(cr, uid, id, terp.get('web_depends', [])) self._update_category(cr, uid, id, terp.get('category', 'Uncategorized')) return res @@ -398,7 +401,9 @@ class module(osv.osv): fp = file(fname, 'wb') fp.write(zipfile) fp.close() - except Exception, e: + except Exception: + self.__logger.exception('Error when trying to create module ' + 'file %s', fname) raise orm.except_orm(_('Error'), _('Can not create the module file:\n %s') % (fname,)) terp = self.get_module_info(mod.name) self.write(cr, uid, mod.id, self.get_values_from_terp(terp)) @@ -417,18 +422,6 @@ class module(osv.osv): for d in depends: cr.execute('INSERT INTO ir_module_module_dependency (module_id, name) values (%s, %s)', (id, d)) - def _update_web_dependencies(self, cr, uid, id, depends=[]): - web_module_pool = self.pool.get('ir.module.web') - res = False - - for d in depends: - ids = web_module_pool.search(cr, uid, [('module','=',d)]) - if len(ids) > 0: - cr.execute("Select id from ir_module_web_dependency where module_id=%s and web_module_id=%s and name=%s", (id, ids[0], d)) - res = cr.fetchone() - if not res: - cr.execute('INSERT INTO ir_module_web_dependency (module_id, web_module_id, name) values (%s, %s, %s)', (id, ids[0], d)) - def _update_category(self, cr, uid, id, category='Uncategorized'): categs = category.split('/') p_id = None @@ -448,7 +441,7 @@ class module(osv.osv): categs = categs[1:] self.write(cr, uid, [id], {'category_id': p_id}) - def update_translations(self, cr, uid, ids, filter_lang=None): + def update_translations(self, cr, uid, ids, filter_lang=None, context={}): logger = netsvc.Logger() if not filter_lang: pool = pooler.get_pool(cr.dbname) @@ -475,7 +468,7 @@ class module(osv.osv): iso_lang = iso_lang.split('_')[0] if os.path.exists(f): logger.notifyChannel("i18n", netsvc.LOG_INFO, 'module %s: loading translation file for language %s' % (mod.name, iso_lang)) - tools.trans_load(cr.dbname, f, lang, verbose=False) + tools.trans_load(cr.dbname, f, lang, verbose=False, context=context) def check(self, cr, uid, ids, context=None): logger = logging.getLogger('init') @@ -491,40 +484,54 @@ class module(osv.osv): logger.critical('module %s: invalid quality certificate: %s', mod.name, mod.certificate) raise osv.except_osv(_('Error'), _('Module %s: Invalid Quality Certificate') % (mod.name,)) -module() - -class web_module_dependency(osv.osv): - _name = "ir.module.web.dependency" - _description = "Web Module dependency" - - def _state(self, cr, uid, ids, name, args, context={}): - result = {} - mod_obj = self.pool.get('ir.module.web') - for md in self.browse(cr, uid, ids): - ids = mod_obj.search(cr, uid, [('module', '=', md.name)]) - if ids: - result[md.id] = mod_obj.read(cr, uid, [ids[0]], ['state'])[0]['state'] + def list_web(self, cr, uid, context=None): + """ list_web(cr, uid, context) -> [module_name] + Lists all the currently installed modules with a web component. + + Returns a list of addon names. + """ + return [ + module['name'] + for module in self.browse(cr, uid, + self.search(cr, uid, + [('web', '=', True), + ('state', 'in', ['installed','to upgrade','to remove'])], + context=context), + context=context)] + def _web_dependencies(self, cr, uid, module, context=None): + for dependency in module.dependencies_id: + (parent,) = self.browse(cr, uid, self.search(cr, uid, + [('name', '=', dependency.name)], context=context), + context=context) + if parent.web: + yield parent.name else: - result[md.id] = 'unknown' - return result - - - _columns = { - 'name': fields.char('Name', size=128), - 'module_id': fields.many2one('ir.module.module', 'Module', select=True, ondelete='cascade'), - 'web_module_id': fields.many2one('ir.module.web', 'Web Module', select=True, ondelete='cascade'), - 'state': fields.function(_state, method=True, type='selection', selection=[ - ('uninstallable','Uninstallable'), - ('uninstalled','Not Installed'), - ('installed','Installed'), - ('to upgrade','To be upgraded'), - ('to remove','To be removed'), - ('to install','To be installed'), - ('unknown', 'Unknown'), - ], string='State', readonly=True), - } + self._web_dependencies( + cr, uid, parent, context=context) + def get_web(self, cr, uid, names, context=None): + """ get_web(cr, uid, [module_name], context) -> [{name, depends, content}] + + Returns the web content of all the named addons. + + The toplevel directory of the zipped content is called 'web', + its final naming has to be managed by the client + """ + modules = self.browse(cr, uid, + self.search(cr, uid, [('name', 'in', names)], context=context), + context=context) + if not modules: return [] + self.__logger.info('Sending web content of modules %s ' + 'to web client', names) + return [ + {'name': module.name, + 'depends': list(self._web_dependencies( + cr, uid, module, context=context)), + 'content': addons.zip_directory( + addons.get_module_resource(module.name, 'web'))} + for module in modules + ] -web_module_dependency() +module() class module_dependency(osv.osv): _name = "ir.module.module.dependency" @@ -542,7 +549,7 @@ class module_dependency(osv.osv): return result _columns = { - 'name': fields.char('Name', size=128), + 'name': fields.char('Name', size=128, select=True), 'module_id': fields.many2one('ir.module.module', 'Module', select=True, ondelete='cascade'), 'state': fields.function(_state, method=True, type='selection', selection=[ ('uninstallable','Uninstallable'), @@ -552,8 +559,6 @@ class module_dependency(osv.osv): ('to remove','To be removed'), ('to install','To be installed'), ('unknown', 'Unknown'), - ], string='State', readonly=True), + ], string='State', readonly=True, select=True), } module_dependency() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/bin/addons/base/module/module_view.xml b/bin/addons/base/module/module_view.xml index 9bb2cdd2769..2d391cdd8e6 100644 --- a/bin/addons/base/module/module_view.xml +++ b/bin/addons/base/module/module_view.xml @@ -40,20 +40,21 @@ <search string="Search modules"> <group col='10' colspan='4'> <filter icon="terp-check" string="Installed" domain="[('state', 'in', ['installed', 'to upgrade', 'to remove'])]"/> - <filter icon="terp-dialog-close" string="Uninstalled" domain="[('state', 'in', ['uninstalled', 'uninstallable'])]"/> + <filter icon="terp-dialog-close" string="Not Installed" domain="[('state', 'in', ['uninstalled', 'uninstallable'])]"/> <filter icon="terp-gtk-jump-to-ltr" string="To be upgraded" domain="[('state','in', ['to upgrade', 'to remove', 'to install'])]"/> <separator orientation="vertical"/> <filter icon="terp-camera_test" string="Certified" domain="[('certificate','<>', False)]"/> <separator orientation="vertical"/> <field name="name"/> - <field name="category_id"/> + <field name="description"/> + <field name="dependencies_id"/> <field name="state"/> </group> <newline/> <group expand="0" string="Group By..." colspan="11" col="11" groups="base.group_extended"> - <filter string="Category" icon="terp-personal" domain="[]" context="{'group_by':'category_id'}"/> <filter string="Author" icon="terp-personal" domain="[]" context="{'group_by':'author'}"/> <separator orientation="vertical"/> + <filter string="Category" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'category_id'}"/> <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/> </group> </search> @@ -67,7 +68,6 @@ <field name="view_type">form</field> <field name="view_mode">tree,form</field> <field name="domain">[('category_id','=',active_id)]</field> - </record> <record id="ir_action_module_category" model="ir.values"> <field eval="'tree_but_open'" name="key2"/> @@ -89,19 +89,26 @@ <field name="name" select="1"/> <field name="certificate" /> <field colspan="4" name="shortdesc" select="2"/> + <field name="category_id"/> + <field name="demo" readonly="1"/> <notebook colspan="4"> <page string="Module"> - <field colspan="4" name="description" select="2"/> - <field name="installed_version"/> - <field name="latest_version"/> - <field name="author" select="2"/> - <field name="website" select="2" widget="url"/> - <field name="maintainer" attrs="{'invisible': [('maintainer', '=', False)]}"/> - <field name="url" widget="url"/> - <field name="contributors" widget="char" attrs="{'invisible': [('contributors', '=', False)]}"/> - <field name="published_version"/> - <field name="license"/> - <field name="demo" readonly="1"/> + <group colspan="4" col="4"> + <group colspan="2" col="2"> + <separator string="Author" colspan="2"/> + <field name="author" select="2"/> + <field name="license"/> + <field name="website" select="2" widget="url" string="Author Website"/> + </group> + <group colspan="2" col="2"> + <separator string="Version" colspan="2"/> + <field name="installed_version"/> + <field name="latest_version"/> + <field name="published_version"/> + </group> + </group> + <separator string="Description" colspan="4"/> + <field colspan="4" name="description" select="2" nolabel="1"/> <newline/> <field name="state" readonly="1" select="1"/> <group col="6" colspan="2"> @@ -121,14 +128,6 @@ </tree> </field> </page> - <page string="Web Dependencies"> - <field colspan="4" name="web_dependencies_id" nolabel="1"> - <tree string="Dependencies"> - <field name="name"/> - <field name="state"/> - </tree> - </field> - </page> <page string="Features" attrs="{'invisible':[('state','!=','installed')]}"> <separator string="Created Menus" colspan="4"/> <field colspan="4" name="menus_by_module" nolabel="1"/> @@ -148,14 +147,15 @@ <field name="arch" type="xml"> <tree colors="blue:state=='to upgrade' or state=='to install';red:state=='uninstalled';grey:state=='uninstallable';black:state=='installed'" string="Modules"> <field name="name"/> + <field name="category_id"/> <field name="shortdesc"/> <field name="author"/> <field name="installed_version"/> <field name="latest_version"/> <field name="state"/> - <button name="button_install" states="uninstalled" string="Schedule for Installation" icon="terp-gtk-jump-to-ltr" type="object" help="Schedule for Installation"/> + <button name="button_install" states="uninstalled" string="Schedule for Installation" icon="terp-gtk-jump-to-ltr" type="object"/> <button name="button_install_cancel" states="to install" string="Cancel Install" icon="gtk-cancel" type="object"/> - <button name="button_upgrade" states="installed" string="Schedule Upgrade" icon="terp-gtk-go-back-rtl" type="object" help="Schedule Upgrade"/> + <button name="button_upgrade" states="installed" string="Schedule Upgrade" icon="terp-gtk-go-back-rtl" type="object"/> <button name="button_uninstall" states="installed" string="Uninstall (beta)" icon="terp-dialog-close" type="object"/> <button name="button_uninstall_cancel" states="to remove" string="Cancel Uninstall" icon="gtk-cancel" type="object"/> <button name="button_upgrade_cancel" states="to upgrade" string="Cancel Upgrade" icon="gtk-cancel" type="object"/> @@ -168,7 +168,8 @@ <field name="view_type">form</field> <field name="view_mode">tree,form</field> <field name="domain"/> - <field name="search_view_id" ref="view_module_filter"/> + <field name="search_view_id" ref="view_module_filter"/> + <field name="help">List all certified modules available to configure your OpenERP. Modules that are installed are flagged as such. You can search for a specific module using the name or the description of the module. You do not need to install modules one by one, you can install many at the same time by clicking on the schedule button in this list. Then, apply the schedule upgrade from Action menu once for all the ones you have scheduled for installation.</field> </record> <menuitem action="open_module_tree" id="menu_module_tree" parent="base.menu_management"/> diff --git a/bin/addons/base/module/module_web.py b/bin/addons/base/module/module_web.py deleted file mode 100644 index 8f65dc3960d..00000000000 --- a/bin/addons/base/module/module_web.py +++ /dev/null @@ -1,46 +0,0 @@ -from osv import fields, osv, orm - -class module_web(osv.osv): - _name = "ir.module.web" - _description = "Web Module" - - _columns = { - 'name': fields.char("Name", size=128, readonly=True, required=True), - 'module': fields.char("Module", size=128, readonly=True, required=True), - 'description': fields.text("Description", readonly=True, translate=True), - 'author': fields.char("Author", size=128, readonly=True), - 'website': fields.char("Website", size=256, readonly=True), - 'state': fields.selection([ - ('uninstallable','Uninstallable'), - ('uninstalled','Not Installed'), - ('installed','Installed') - ], string='State', readonly=True) - } - - _defaults = { - 'state': lambda *a: 'uninstalled', - } - _order = 'name' - - _sql_constraints = [ - ('name_uniq', 'unique (name)', 'The name of the module must be unique !'), - ] - - def update_module_list(self, cr, uid, modules, context={}): - - for module in modules: - mod_name = module['name'] - ids = self.search(cr, uid, [('name','=',mod_name)]) - if ids: - self.write(cr, uid, ids, module) - else: - self.create(cr, uid, module) - - def button_install(self, cr, uid, ids, context={}): - return self.write(cr, uid, ids, {'state': 'installed'}, context) - - def button_uninstall(self, cr, uid, ids, context={}): - return self.write(cr, uid, ids, {'state': 'uninstalled'}, context) - -module_web() - diff --git a/bin/addons/base/module/module_web_view.xml b/bin/addons/base/module/module_web_view.xml deleted file mode 100644 index 32e927b70e7..00000000000 --- a/bin/addons/base/module/module_web_view.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data> - - <record id="module_web_tree" model="ir.ui.view"> - <field name="name">ir.module.web.tree</field> - <field name="model">ir.module.web</field> - <field name="type">tree</field> - <field name="arch" type="xml"> - <tree> - <field name="name"/> - <field name="module"/> - <field name="description"/> - <field name="author"/> - <field name="state"/> - <button name="button_install" string="Install" type="object" states="uninstalled" context="{'reload': 1}"/> - <button name="button_uninstall" string="Uninstall" type="object" states="installed" context="{'reload': 1}"/> - </tree> - </field> - </record> - - <record id="open_module_web_list" model="ir.actions.url"> - <field name="name">web_module_list</field> - <field name="url">/openerp/modules</field> - </record> - <menuitem name="Web Modules" action="open_module_web_list" id="open_module_web_list_url" type="url" parent="base.menu_management"/> - - </data> -</openerp> diff --git a/bin/addons/base/module/module_wizard.xml b/bin/addons/base/module/module_wizard.xml deleted file mode 100644 index b989fc56041..00000000000 --- a/bin/addons/base/module/module_wizard.xml +++ /dev/null @@ -1,113 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data> - <record id="wizard_base_module_import" model="ir.actions.wizard"> - <field name="name">Import module</field> - <field name="wiz_name">base.module.import</field> - </record> - <menuitem action="wizard_base_module_import" id="menu_wizard_module_import" parent="menu_management" type="wizard"/> - - <record id="wizard_update" model="ir.actions.wizard"> - <field name="name">Update Modules List</field> - <field name="wiz_name">module.module.update</field> - </record> - <menuitem action="wizard_update" icon="STOCK_CONVERT" id="menu_module_update" parent="menu_management" type="wizard"/> - - <wizard id="wizard_upgrade" model="ir.module.module" name="module.upgrade" string="Apply Scheduled Upgrades"/> - - - - <menuitem action="wizard_upgrade" id="menu_wizard_upgrade" parent="menu_management" type="wizard"/> - - <record id="wizard_lang_install" model="ir.actions.wizard"> - <field name="name">Load an Official Translation</field> - <field name="wiz_name">module.lang.install</field> - </record> - <menuitem action="wizard_lang_install" id="menu_wizard_lang_install" parent="menu_translation" type="wizard"/> - - <record id="wizard_lang_export" model="ir.ui.view"> - <field name="name">Export a Translation File</field> - <field name="model">wizard.module.lang.export</field> - <field name="type">form</field> - <field name="arch" type="xml"> - <form col="3" string="Export language"> - <notebook> - <page string="Export Data"> - <group col="2" fill="0" states="choose"> - <separator colspan="2" string="Export translation file"/> - <field name="lang" width="300"/> - <field name="format" required="1"/> - <field height="200" name="modules" width="500"/> - <field invisible="1" name="state"/> - </group> - <group col="1" fill="0" states="get"> - <separator string="Export done"/> - <field name="name" invisible="1"/> - <field name="data" nolabel="1" readonly="1" fieldname="name"/> - <field height="80" name="advice" nolabel="1"/> - </group> - </page> - <page string="Help"> - <label align="0.0" colspan="4" string="The official translations pack of all OpenERP/OpenObjects module are managed through launchpad. We use their online interface to synchronize all translations efforts."/> - <label align="0.0" colspan="4" string="To improve some terms of the official translations of OpenERP, you should modify the terms directly on the launchpad interface. If you made lots of translations for your own module, you can also publish all your translation at once."/> - <label align="0.0" colspan="4" string="To browse official translations, you can visit this link: "/> - <label align="0.0" colspan="4" string="https://translations.launchpad.net/openobject"/> - </page> - </notebook> - - <group col="2" colspan="3" fill="0"> - <button icon="gtk-cancel" name="act_cancel" special="cancel" states="choose" string="Cancel" type="object"/> - <button icon="gtk-ok" name="act_getfile" states="choose" string="Get file" type="object"/> - <button icon="gtk-close" name="act_destroy" special="cancel" states="get" string="Close" type="object"/> - </group> - </form> - </field> - </record> - - <record id="action_wizard_lang_export" model="ir.actions.act_window"> - <field name="name">Export a Translation File</field> - <field name="type">ir.actions.act_window</field> - <field name="res_model">wizard.module.lang.export</field> - <field name="view_type">form</field> - <field name="view_mode">form</field> - <field name="target">new</field> - </record> - <menuitem action="action_wizard_lang_export" id="menu_wizard_lang_export" parent="menu_translation_export"/> - - <record id="wizard_lang_import" model="ir.actions.wizard"> - <field name="name">Import a Translation File</field> - <field name="wiz_name">module.lang.import</field> - </record> - <menuitem action="wizard_lang_import" id="menu_wizard_lang_import" parent="menu_translation_export" type="wizard"/> - - <record id="wizard_update_translations" model="ir.ui.view"> - <field name="name">Update Translations</field> - <field name="model">wizard.module.update_translations</field> - <field name="type">form</field> - <field name="arch" type="xml"> - <form col="3" string="Update Translations"> - <image name="gtk-dialog-info"/> - <group col="2" fill="0" height="500"> - <field name="lang" width="300"/> - </group> - <label align="0.0" colspan="4" string="This wizard will detect new terms in the application so that you can update them manually."/> - <separator colspan="4"/> - <group col="2" colspan="4" fill="0"> - <button icon="gtk-cancel" name="act_cancel" special="cancel" string="Cancel" type="object"/> - <button icon="gtk-ok" name="act_update" string="Update" type="object"/> - </group> - </form> - </field> - </record> - <record id="action_wizard_update_translations" model="ir.actions.act_window"> - <field name="name">Resynchronise Terms</field> - <field name="type">ir.actions.act_window</field> - <field name="res_model">wizard.module.update_translations</field> - <field name="view_type">form</field> - <field name="view_mode">form</field> - <field name="target">new</field> - </record> - <menuitem action="action_wizard_update_translations" id="menu_wizard_update_translations" parent="menu_translation_app"/> - - </data> -</openerp> diff --git a/bin/addons/base/module/wizard/__init__.py b/bin/addons/base/module/wizard/__init__.py index c0af5977b21..a4133a50113 100644 --- a/bin/addons/base/module/wizard/__init__.py +++ b/bin/addons/base/module/wizard/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # @@ -15,19 +15,18 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## -import wizard_update_module -import wizard_module_upgrade -import wizard_configuration -import wizard_module_lang_install -import add_new -import wizard_export_lang -import wizard_import_lang -import wizard_module_import -import wizard_update_translations +import base_module_import +import base_module_update +import base_language_install +import base_import_language +import base_module_upgrade +import base_module_configuration +import base_export_language +import base_update_translations # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bin/addons/base/module/wizard/wizard_export_lang.py b/bin/addons/base/module/wizard/base_export_language.py index b59351be61b..1b43b561ac3 100644 --- a/bin/addons/base/module/wizard/wizard_export_lang.py +++ b/bin/addons/base/module/wizard/base_export_language.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## @@ -27,7 +27,7 @@ from osv import fields,osv from tools.translate import _ from tools.misc import get_iso_codes -class wizard_export_lang(osv.osv_memory): +class base_language_export(osv.osv_memory): def _get_languages(self, cr, uid, context): lang_obj=pooler.get_pool(cr.dbname).get('res.lang') @@ -67,7 +67,8 @@ class wizard_export_lang(osv.osv_memory): buf.close() return self.write(cr, uid, ids, {'state':'get', 'data':out, 'advice':this.advice, 'name':this.name}, context=context) - _name = "wizard.module.lang.export" + _name = "base.language.export" + _inherit = "ir.wizard.screen" _columns = { 'name': fields.char('Filename', 16, readonly=True), 'lang': fields.selection(_get_languages, 'Language', help='To export a new language, do not select a language.'), # not required: unset = new language @@ -78,11 +79,11 @@ class wizard_export_lang(osv.osv_memory): 'state': fields.selection( ( ('choose','choose'), # choose language ('get','get'), # get the file ) ), - } - _defaults = { 'state': lambda *a: 'choose', - 'name': lambda *a: 'lang.tar.gz' - } -wizard_export_lang() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + } + _defaults = { + 'state': lambda *a: 'choose', + 'name': lambda *a: 'lang.tar.gz' + } +base_language_export() +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file diff --git a/bin/addons/base/module/wizard/base_export_language_view.xml b/bin/addons/base/module/wizard/base_export_language_view.xml new file mode 100644 index 00000000000..c908c5ce03a --- /dev/null +++ b/bin/addons/base/module/wizard/base_export_language_view.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="wizard_lang_export" model="ir.ui.view"> + <field name="name">Export Translations</field> + <field name="model">base.language.export</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Export Translations"> + <group col="8"> + <group colspan="3"> + <field name="config_logo" widget="image" width="220" height="130" nolabel="1" colspan="1"/> + <newline/> + <label colspan="4" width="220" string="OpenERP translations (core, modules, clients) are managed through Launchpad.net, our open source project management facility. We use their online interface to synchronize all translations efforts."/> + <label colspan="4" width="220" string="To improve or expand the official translations, you should use directly Lauchpad's web interface (Rosetta). If you need to perform mass translation, Launchpad also allows uploading full .po files at once"/> + <label colspan="4" width="220"/> + <label colspan="4" width="220" string="To browse official translations, you can start with these links:"/> + <label colspan="4" width="220" string="https://help.launchpad.net/Translations"/> + <label colspan="4" width="220" string="https://translations.launchpad.net/openobject"/> + </group> + <separator orientation="vertical" rowspan="15"/> + <group colspan="4"> + <group colspan="4" states="choose"> + <separator colspan="4" string="Export Translation"/> + <field name="lang"/> + <field name="format" required="1"/> + <field height="200" name="modules" nolabel="1" colspan="4"/> + <field invisible="1" name="state"/> + </group> + <group colspan="4" states="get"> + <separator string="Export done" colspan="4"/> + <field name="name" invisible="1" colspan="4"/> + <field name="data" nolabel="1" readonly="1" fieldname="name" colspan="4"/> + <field height="80" name="advice" nolabel="1" colspan="4"/> + </group> + </group> + <group colspan="8" col="8" states="choose"> + <separator string="" colspan="8"/> + <label colspan="6" width="220"/> + <button icon="gtk-cancel" name="act_cancel" special="cancel" string="_Close" type="object"/> + <button icon="gtk-ok" name="act_getfile" string="_Export" type="object"/> + </group> + <group colspan="8" col="8" states="get"> + <separator string="" colspan="8"/> + <label colspan="7" width="220"/> + <button icon="gtk-close" name="act_destroy" special="cancel" string="_Close" type="object"/> + </group> + </group> + </form> + </field> + </record> + + <record id="action_wizard_lang_export" model="ir.actions.act_window"> + <field name="name">Export Translation</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">base.language.export</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + <menuitem action="action_wizard_lang_export" id="menu_wizard_lang_export" parent="menu_translation_export"/> + </data> +</openerp> diff --git a/bin/addons/base/module/wizard/base_import_language.py b/bin/addons/base/module/wizard/base_import_language.py new file mode 100644 index 00000000000..6608ade03ef --- /dev/null +++ b/bin/addons/base/module/wizard/base_import_language.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +import tools +import base64 +from tempfile import TemporaryFile +from osv import osv, fields + +class base_language_import(osv.osv_memory): + """ Language Import """ + + _name = "base.language.import" + _description = "Language Import" + _inherit = "ir.wizard.screen" + + _columns = { + 'name': fields.char('Language Name',size=64 , required=True), + 'code': fields.char('Code (eg:en__US)',size=5 , required=True), + 'data': fields.binary('File', required=True), + } + + def import_lang(self, cr, uid, ids, context): + """ + Import Language + @param cr: the current row, from the database cursor. + @param uid: the current user’s ID for security checks. + @param ids: the ID or list of IDs + @param context: A standard dictionary + """ + + import_data = self.browse(cr, uid, ids)[0] + fileobj = TemporaryFile('w+') + fileobj.write(base64.decodestring(import_data.data)) + + # now we determine the file format + fileobj.seek(0) + first_line = fileobj.readline().strip().replace('"', '').replace(' ', '') + fileformat = first_line.endswith("type,name,res_id,src,value") and 'csv' or 'po' + fileobj.seek(0) + + tools.trans_load_data(cr.dbname, fileobj, fileformat, import_data.code, lang_name=import_data.name) + fileobj.close() + return {} + +base_language_import()
\ No newline at end of file diff --git a/bin/addons/base/module/wizard/base_import_language_view.xml b/bin/addons/base/module/wizard/base_import_language_view.xml new file mode 100644 index 00000000000..d313afc4080 --- /dev/null +++ b/bin/addons/base/module/wizard/base_import_language_view.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_base_import_language" model="ir.ui.view"> + <field name="name">Import Translation</field> + <field name="model">base.language.import</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Import Translation"> + <group col="8"> + <group colspan="3"> + <field name="config_logo" widget="image" width="220" height="130" nolabel="1" colspan="1"/> + <newline/> + <label colspan="4" width="220" string="Supported file formats: *.csv (Comma-separated values) or *.po (GetText Portable Objects)"/> + <label colspan="4" width="220" string="Please double-check that the file encoding is set to UTF-8 (sometimes called Unicode) when the translator exports it."/> + <label colspan="4" width="220"/> + <label colspan="4" width="220" string="When using CSV format, please also check that the first line of your file is one of the following:"/> + <label colspan="4" width="220" string="- type,name,res_id,src,value"/> + <label colspan="4" width="220" string="- module,type,name,res_id,src,value"/> + </group> + <separator orientation="vertical" rowspan="15"/> + <group colspan="4" col="4"> + <separator string="Import Translation" colspan="4"/> + <label colspan="4" nolabel="1" string="If you need another language than the official ones available, you can import a language pack from here. Other OpenERP languages than the official ones can be found on launchpad."/> + <newline/> + <field name="name" width="200"/> + <field name="code"/> + <field name="data" colspan="4"/> + </group> + <group colspan="8" col="8"> + <separator string="" colspan="8"/> + <label colspan="6" width="220"/> + <button special="cancel" string="_Close" icon="gtk-cancel"/> + <button name="import_lang" string="_Import" type="object" icon="gtk-ok"/> + </group> + </group> + </form> + </field> + </record> + + <record id="action_view_base_import_language" model="ir.actions.act_window"> + <field name="name">Import Translation</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">base.language.import</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + <menuitem + action="action_view_base_import_language" + id="menu_view_base_import_language" + parent="menu_translation_export"/> + + </data> +</openerp> diff --git a/bin/addons/base/module/wizard/base_language_install.py b/bin/addons/base/module/wizard/base_language_install.py new file mode 100644 index 00000000000..9cdae41ad2b --- /dev/null +++ b/bin/addons/base/module/wizard/base_language_install.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +import tools +from osv import osv, fields + +class base_language_install(osv.osv_memory): + """ Install Language""" + + _name = "base.language.install" + _inherit = "ir.wizard.screen" + _description = "Install Language" + + _columns = { + 'lang': fields.selection(tools.scan_languages(),'Language', required=True), + 'overwrite': fields.boolean('Overwrite Existing Terms', help="If you check this box, your customized translations will be overwritten and replaced by the official ones."), + 'state':fields.selection([('init','init'),('done','done')], 'state', readonly=True), + } + _defaults = { + 'state': 'init', + 'overwrite': False + } + def lang_install(self, cr, uid, ids, context): + language_obj = self.browse(cr, uid, ids)[0] + lang = language_obj.lang + if lang: + modobj = self.pool.get('ir.module.module') + mids = modobj.search(cr, uid, [('state', '=', 'installed')]) + if language_obj.overwrite: + context = {'overwrite': True} + modobj.update_translations(cr, uid, mids, lang, context or {}) + self.write(cr, uid, ids, {'state': 'done'}, context=context) + return False +base_language_install() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bin/addons/base/module/wizard/base_language_install_view.xml b/bin/addons/base/module/wizard/base_language_install_view.xml new file mode 100644 index 00000000000..d207ea9ea29 --- /dev/null +++ b/bin/addons/base/module/wizard/base_language_install_view.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_base_language_install" model="ir.ui.view"> + <field name="name">Load Official Translation</field> + <field name="model">base.language.install</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Load Official Translation"> + <group col="8"> + <group colspan="3"> + <field name="config_logo" widget="image" width="220" height="130" nolabel="1" colspan="1"/> + <newline/> + <label colspan="4" width="220" string="This wizard helps you add a new language to your OpenERP system. After loading a new language it becomes available as default interface language for users and partners."/> + <label colspan="4" width="220"/> + <label colspan="4" width="220" string="Please be patient, this operation may take a few minutes (depending on the number of modules currently installed)..."/> + <field name="state" invisible="1"/> + </group> + <separator orientation="vertical" rowspan="15"/> + <group colspan="4"> + <separator string="Load an Official Translation" colspan="4"/> + <group states="init" colspan="4"> + <field name="lang" colspan="4"/> + <field name="overwrite" colspan="4" groups="base.group_extended"/> + </group> + <group states="done" colspan="4"> + <label string="The selected language has been successfully installed. +You must change the preferences of the user and open a new menu to view the changes." colspan="4"/> + </group> + </group> + <group colspan="8" col="8" states="init"> + <separator string="" colspan="8"/> + <label colspan="6" width="220"/> + <button special="cancel" string="Cancel" icon="gtk-cancel"/> + <button name="lang_install" string="Load" type="object" icon="gtk-ok"/> + </group> + <group colspan="8" col="8" states="done"> + <separator string="" colspan="8"/> + <label colspan="7" width="220"/> + <button special="cancel" string="Close" icon="gtk-ok"/> + </group> + </group> + </form> + </field> + </record> + + <record id="action_view_base_language_install" model="ir.actions.act_window"> + <field name="name">Load Official Translation</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">base.language.install</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + <menuitem + name="Load an Official Translation" + action="action_view_base_language_install" + id="menu_view_base_language_install" + parent="menu_translation" sequence="2"/> + </data> +</openerp> + diff --git a/bin/addons/base/module/wizard/base_module_configuration.py b/bin/addons/base/module/wizard/base_module_configuration.py new file mode 100644 index 00000000000..866b22905e0 --- /dev/null +++ b/bin/addons/base/module/wizard/base_module_configuration.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from osv import osv +from tools.translate import _ + +class base_module_configuration(osv.osv_memory): + + _name = "base.module.configuration" + + def start(self, cr, uid, ids, context=None): + todo_ids = self.pool.get('ir.actions.todo').search(cr, uid, ['|', '|', ('restart','=','always'), ('state', '=', 'open'), '&', ('state', '=', 'skip'), ('restart', '=', 'onskip')]) + if not todo_ids: + # When there is no wizard todo it will display message + data_obj = self.pool.get('ir.model.data') + result = data_obj._get_id(cr, uid, 'base', 'view_base_module_configuration_form') + view_id = data_obj.browse(cr, uid, result).res_id + value = { + 'name': _('System Configuration done'), + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'base.module.configuration', + 'view_id': [view_id], + 'type': 'ir.actions.act_window', + 'target': 'new' + } + return value + # Run the config wizards + config_pool = self.pool.get('res.config') + return config_pool.start(cr, uid, ids, context=context) + +base_module_configuration() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bin/addons/base/module/wizard/base_module_configuration_view.xml b/bin/addons/base/module/wizard/base_module_configuration_view.xml new file mode 100644 index 00000000000..2d0b31b7126 --- /dev/null +++ b/bin/addons/base/module/wizard/base_module_configuration_view.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_base_module_configuration_form" model="ir.ui.view"> + <field name="name">Module Configuration</field> + <field name="model">base.module.configuration</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="System Configuration Done"> + <label align="0.0" string="All pending configuration wizards have been executed. You may restart individual wizards via the list of configuration wizards." colspan="4"/> + <separator string="" colspan="4"/> + <newline/> + <button special="cancel" string="_Ok" icon="gtk-ok"/> + </form> + </field> + </record> + + + <record id="action_start_configurator" model="ir.actions.server"> + <field name="name">Start Configuration</field> + <field name="model_id" ref="model_base_module_configuration"/> + <field name="state">code</field> + <field name="code">action = obj.start([])</field> + </record> + + <menuitem name="Start Configuration" + action="action_start_configurator" + id="menu_view_base_module_configuration" parent="base.menu_config" + type="server" icon="STOCK_EXECUTE" sequence="100" /> + + <record model="ir.values" id="action_todo_config"> + <field name="model_id" ref="model_ir_actions_todo" /> + <field name="object" eval="1" /> + <field name="name">Start Configuration</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.server,' + str(ref('action_start_configurator'))" /> + <field name="key">action</field> + <field name="model">ir.actions.todo</field> + </record> + <record id="ir_ui_view_sc_configuration" model="ir.ui.view_sc"> + <field name="name">Reconfigure</field> + <field name="resource">ir.ui.menu</field> + <field name="user_id" ref="base.user_root"/> + <field name="res_id" ref="menu_view_base_module_configuration"/> + </record> + + </data> +</openerp> diff --git a/bin/addons/base/module/wizard/base_module_import.py b/bin/addons/base/module/wizard/base_module_import.py new file mode 100644 index 00000000000..05c3b18198d --- /dev/null +++ b/bin/addons/base/module/wizard/base_module_import.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +import os +import tools + +import zipfile +from StringIO import StringIO +import base64 +from tools.translate import _ +from osv import osv, fields + +class base_module_import(osv.osv_memory): + """ Import Module """ + + _name = "base.module.import" + _inherit = "ir.wizard.screen" + _description = "Import Module" + + _columns = { + 'module_file': fields.binary('Module .ZIP file', required=True), + 'state':fields.selection([('init','init'),('done','done')], 'state', readonly=True), + 'module_name': fields.char('Module Name', size=128), + } + + _defaults = { + 'state': 'init', + } + + def importzip(self, cr, uid, ids, context): + (data,) = self.browse(cr, uid, ids , context=context) + module_data = data.module_file + + val = base64.decodestring(module_data) + fp = StringIO() + fp.write(val) + fdata = zipfile.ZipFile(fp, 'r') + fname = fdata.namelist()[0] + module_name = os.path.split(fname)[0] + + ad = tools.config['addons_path'].split(",")[-1] + + fname = os.path.join(ad, module_name+'.zip') + try: + fp = file(fname, 'wb') + fp.write(val) + fp.close() + except IOError: + raise osv.except_osv(_('Error !'), _('Can not create the module file: %s !') % (fname,) ) + + self.pool.get('ir.module.module').update_list(cr, uid, {'module_name': module_name,}) + self.write(cr, uid, ids, {'state':'done', 'module_name': module_name}, context) + return False + + def action_module_open(self, cr, uid, ids, context): + (data,) = self.browse(cr, uid, ids , context=context) + return { + 'domain': str([('name', '=', data.module_name)]), + 'name': 'Modules', + 'view_type': 'form', + 'view_mode': 'tree,form', + 'res_model': 'ir.module.module', + 'type': 'ir.actions.act_window', + } + +base_module_import() + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file diff --git a/bin/addons/base/module/wizard/base_module_import_view.xml b/bin/addons/base/module/wizard/base_module_import_view.xml new file mode 100644 index 00000000000..8e43789b057 --- /dev/null +++ b/bin/addons/base/module/wizard/base_module_import_view.xml @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_base_module_import" model="ir.ui.view"> + <field name="name">Module Import</field> + <field name="model">base.module.import</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Import module"> + <group col="8"> + <group colspan="3" col="1"> + <field name="config_logo" widget="image" width="220" height="130" nolabel="1" colspan="1"/> + <newline/> + <label width="220" string="This wizard helps you add a new language to you OpenERP system. After loading a new language it becomes available as default interface language for users and partners."/> + <label width="220"/> + <label width="220" string="Please be patient, this operation may take a few minutes (depending on the number of modules currently installed)..."/> + <field name="state" invisible="1"/> + </group> + <separator orientation="vertical" rowspan="5"/> + <group colspan="4"> + <separator string="Module Import" colspan="4"/> + <group states="init" col="4"> + <label string="Select module package to import (.zip file):" colspan="4"/> + <field name="module_file" colspan="4"/> + </group> + <group states="done" col="4"> + <label string="Module file successfully imported!" colspan="4"/> + </group> + </group> + <group colspan="8" col="8" states="init"> + <separator string="" colspan="8"/> + <label colspan="6" width="220"/> + <button special="cancel" string="Cancel" icon="gtk-cancel"/> + <button name="importzip" string="Import module" type="object" icon="gtk-apply"/> + </group> + <group colspan="8" col="8" states="done"> + <separator string="" colspan="8"/> + <label colspan="6" width="220"/> + <button special="cancel" string="Close" icon="gtk-ok"/> + <button name="action_module_open" string="Open Modules" type="object" icon="gtk-go-forward"/> + </group> + </group> + </form> + </field> + </record> + + <record id="action_view_base_module_import" model="ir.actions.act_window"> + <field name="name">Module Import</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">base.module.import</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + <menuitem + name="Import Module" + action="action_view_base_module_import" + id="menu_view_base_module_import" + parent="menu_management" + sequence="1"/> + + </data> +</openerp> + diff --git a/bin/addons/base/module/wizard/add_new.py b/bin/addons/base/module/wizard/base_module_scan.py index c6eddab2adb..d47e091955f 100644 --- a/bin/addons/base/module/wizard/add_new.py +++ b/bin/addons/base/module/wizard/base_module_scan.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). -# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>). +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -16,34 +15,26 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## - import os -import re import glob -import time import imp import tools -import wizard -import pooler import zipfile +from osv import osv -module_name_re = re.compile('.*addons.(.*?).__terp__.py$') +class base_module_scan(osv.osv_memory): + """ scan module """ -_info_arch = '''<?xml version="1.0"?> -<form string="Scan for new modules"> - <label string="This function will check if you installed new modules in the 'addons' path of your server installation." colspan="4" /> -</form> -''' -_info_fields = {} + _name = "base.module.scan" + _description = "scan module" -class wizard_install_module(wizard.interface): - def watch_dir(self, cr, uid, data, context): - mod_obj = pooler.get_pool(cr.dbname).get('ir.module.module') + def watch_dir(self, cr, uid, ids, context): + mod_obj = self.pool.get('ir.module.module') all_mods = mod_obj.read(cr, uid, mod_obj.search(cr, uid, []), ['name', 'state']) known_modules = [x['name'] for x in all_mods] ls_ad = glob.glob(os.path.join(tools.config['addons_path'], '*', '__terp__.py')) @@ -79,18 +70,4 @@ class wizard_install_module(wizard.interface): mod_obj.write(cr, uid, [mod['id']], {'state': 'uninstalled'}) return {} - states = { - 'init': { - 'actions': [], - 'result': {'type':'form', 'arch': _info_arch, 'fields': _info_fields, 'state':[('end','Cancel','gtk-cancel'),('addmod','Check new modules','gtk-ok')]} - }, - 'addmod': { - 'actions': [watch_dir], - 'result': {'type':'state', 'state':'end'} - }, - } -wizard_install_module('module.module.scan') - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +base_module_scan()
\ No newline at end of file diff --git a/bin/addons/base/module/wizard/base_module_scan_view.xml b/bin/addons/base/module/wizard/base_module_scan_view.xml new file mode 100644 index 00000000000..a039c3122e1 --- /dev/null +++ b/bin/addons/base/module/wizard/base_module_scan_view.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_base_module_scan" model="ir.ui.view"> + <field name="name">Module Scan</field> + <field name="model">base.module.scan</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Scan for new modules"> + <separator string="" colspan="4"/> + <label string="This function will check if you installed new modules in the 'addons' path of your server installation." colspan="4" /> + <separator string="" colspan="4"/> + <newline/> + <group colspan="4"> + <button special="cancel" string="Close" icon="gtk-cancel"/> + <button name="watch_dir" string="Check new modules" type="object" icon="gtk-ok"/> + </group> + </form> + </field> + </record> + + <record id="action_view_base_module_scan" model="ir.actions.act_window"> + <field name="name">Module Scan</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">base.module.scan</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + </data> +</openerp> + diff --git a/bin/addons/base/module/wizard/base_module_update.py b/bin/addons/base/module/wizard/base_module_update.py new file mode 100644 index 00000000000..a0d21840d90 --- /dev/null +++ b/bin/addons/base/module/wizard/base_module_update.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## +from osv import osv, fields + +class base_module_update(osv.osv_memory): + """ Update Module """ + + _name = "base.module.update" + _description = "Update Module" + _inherit = "ir.wizard.screen" + + _columns = { + 'update': fields.integer('Number of modules updated', readonly=True), + 'add': fields.integer('Number of modules added', readonly=True), + 'state':fields.selection([('init','init'),('done','done')], 'state', readonly=True), + } + + _defaults = { + 'state': 'init', + } + + def update_module(self, cr, uid, ids, context=None): + module_obj = self.pool.get('ir.module.module') + update, add = module_obj.update_list(cr, uid,) + self.write(cr, uid, ids, {'update': update, 'add': add, 'state': 'done'}, context=context) + return False + + def action_module_open(self, cr, uid, ids, context): + res = { + 'domain': str([]), + 'name': 'Modules', + 'view_type': 'form', + 'view_mode': 'tree,form', + 'res_model': 'ir.module.module', + 'view_id': False, + 'type': 'ir.actions.act_window', + } + return res + + +base_module_update() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file diff --git a/bin/addons/base/module/wizard/base_module_update_view.xml b/bin/addons/base/module/wizard/base_module_update_view.xml new file mode 100644 index 00000000000..51f0c94f31c --- /dev/null +++ b/bin/addons/base/module/wizard/base_module_update_view.xml @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_base_module_update" model="ir.ui.view"> + <field name="name">Module Update</field> + <field name="model">base.module.update</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Update Module List"> + <group col="8"> + <group colspan="3"> + <field name="config_logo" widget="image" width="220" height="130" nolabel="1" colspan="1"/> + <newline/> + <label colspan="4" width="220" string="This wizard will scan all module repositories on the server side to detect newly added modules as well as any change to existing modules."/> + <label colspan="4" width="220"/> + <label colspan="4" width="220" string="Please be patient, as this operation may take a few seconds..."/> + <field name="state" invisible="1"/> + </group> + <separator orientation="vertical" rowspan="15"/> + <group colspan="4"> + <separator string="Module update result" colspan="4"/> + <group states="init" colspan="4"> + <label string="Click on Update below to start the process..." colspan="4"/> + </group> + <group states="done" colspan="4"> + <field name="update" colspan="4"/> + <field name="add" colspan="4"/> + </group> + </group> + <group colspan="8" col="8" states="init"> + <separator string="" colspan="8"/> + <label colspan="6" width="220"/> + <button special="cancel" string="Cancel" icon="gtk-cancel"/> + <button name="update_module" string="Update" type="object" icon="gtk-ok"/> + </group> + <group colspan="8" col="8" states="done"> + <separator string="" colspan="8"/> + <label colspan="6" width="220"/> + <button special="cancel" string="Close" icon="gtk-ok"/> + <button name="action_module_open" string="Open Modules" type="object" icon="gtk-go-forward"/> + </group> + </group> + </form> + </field> + </record> + + <record id="action_view_base_module_update" model="ir.actions.act_window"> + <field name="name">Module Update</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">base.module.update</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + <menuitem + name="Update Modules List" + action="action_view_base_module_update" + id="menu_view_base_module_update" + parent="menu_management" + sequence="2" + icon="STOCK_CONVERT"/> + + </data> +</openerp> diff --git a/bin/addons/base/module/wizard/base_module_upgrade.py b/bin/addons/base/module/wizard/base_module_upgrade.py new file mode 100644 index 00000000000..4db4028bdb0 --- /dev/null +++ b/bin/addons/base/module/wizard/base_module_upgrade.py @@ -0,0 +1,118 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +import pooler +from osv import osv, fields + +class base_module_upgrade(osv.osv_memory): + """ Module Upgrade """ + + _name = "base.module.upgrade" + _description = "Module Upgrade" + + _columns = { + '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): + """ + This function checks for precondition before wizard executes + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param fields: List of fields for default value + @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))} + + def upgrade_module(self, cr, uid, ids, context): + pool = pooler.get_pool(cr.dbname) + mod_obj = self.pool.get('ir.module.module') + data_obj = self.pool.get('ir.model.data') + 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 osv.except_osv('Unmet dependency !', 'Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages)) + mod_obj.download(cr, uid, ids, context=context) + cr.commit() + _, pool = pooler.restart_pool(cr.dbname, update_module=True) + + id2 = data_obj._get_id(cr, uid, 'base', 'view_base_module_upgrade_install') + if id2: + id2 = data_obj.browse(cr, uid, id2, context=context).res_id + + return { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'base.module.upgrade', + 'views': [(id2, 'form')], + 'view_id': False, + 'type': 'ir.actions.act_window', + 'target': 'new', + } + + def config(self, cr, uid, ids, context=None): + return self.pool.get('res.config').next(cr, uid, [], context=context) + +base_module_upgrade() diff --git a/bin/addons/base/module/wizard/base_module_upgrade_view.xml b/bin/addons/base/module/wizard/base_module_upgrade_view.xml new file mode 100644 index 00000000000..b8bb282d6ed --- /dev/null +++ b/bin/addons/base/module/wizard/base_module_upgrade_view.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_base_module_upgrade" model="ir.ui.view"> + <field name="name">Module Upgrade</field> + <field name="model">base.module.upgrade</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="System Update"> + <group colspan="2" col="4"> + <label align="0.0" string="Your system will be updated." colspan="4"/> + <label align="0.0" string="Note that this operation might take a few minutes." colspan="4"/> + <separator string="Modules to update" colspan="4"/> + <field name="module_info" nolabel="1" colspan="4"/> + <separator string="" colspan="4"/> + <button special="cancel" string="Cancel" icon="gtk-cancel"/> + <button name="upgrade_module" string="Start update" type="object" icon="gtk-ok"/> + </group> + </form> + </field> + </record> + + <record id="action_view_base_module_upgrade" model="ir.actions.act_window"> + <field name="name">Module Upgrade</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">base.module.upgrade</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + <menuitem + name="Apply Scheduled Upgrades" + action="action_view_base_module_upgrade" + id="menu_view_base_module_upgrade" + parent="menu_management" + sequence="3"/> + + <act_window id="action_view_base_module_upgrade_window" + key2="client_action_multi" name="Apply Scheduled Upgrades" + res_model="base.module.upgrade" src_model="ir.module.module" + view_mode="form" target="new" view_type="form" /> + + <record id="view_base_module_upgrade_install" 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="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="Cancel" icon="gtk-cancel"/> + <button name="config" string="Start configuration" type="object" icon="gtk-ok"/> + </form> + </field> + </record> + + <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> + <field name="res_model">base.module.upgrade</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="view_id" ref="view_base_module_upgrade_install"/> + <field name="target">new</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/bin/addons/base/module/wizard/wizard_update_translations.py b/bin/addons/base/module/wizard/base_update_translations.py index 85914ff0164..b413e9d7093 100644 --- a/bin/addons/base/module/wizard/wizard_update_translations.py +++ b/bin/addons/base/module/wizard/base_update_translations.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## @@ -24,18 +24,18 @@ import tools import pooler import cStringIO -class update_translations(osv.osv_memory): +class base_update_translations(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), ('translatable', '=', True),]) langs=lang_obj.browse(cr, uid, ids) return [(lang.code, lang.name) for lang in langs] - + def _get_lang_name(self, cr, uid, lang_code): lang_obj=pooler.get_pool(cr.dbname).get('res.lang') ids=lang_obj.search(cr, uid, [('code', '=', lang_code)]) if not ids: - raise osv.orm_except('Bad lang') + raise osv.except_osv(_('No language with code "%s" exists') % lang_code) lang = lang_obj.browse(cr, uid, ids[0]) return lang.name def act_cancel(self, cr, uid, ids, context=None): @@ -50,9 +50,22 @@ class update_translations(osv.osv_memory): buf.close() return {'type': 'ir.actions.act_window_close'} - _name = 'wizard.module.update_translations' + def default_get(self, cr, uid, fields, context=None): + res = super(base_update_translations, self).default_get(cr, uid, fields, context=context) + + if context.get('active_model') != "res.lang": + return res + + record_id = context and context.get('active_id', False) or False + if record_id: + lang = self.pool.get('res.lang').browse(cr, uid, record_id).code + res.update(lang=lang) + return res + + _name = 'base.update.translations' + _inherit = "ir.wizard.screen" _columns = { 'lang': fields.selection(_get_languages, 'Language', required=True), } -update_translations() +base_update_translations()
\ No newline at end of file diff --git a/bin/addons/base/module/wizard/base_update_translations_view.xml b/bin/addons/base/module/wizard/base_update_translations_view.xml new file mode 100644 index 00000000000..60d30440ca1 --- /dev/null +++ b/bin/addons/base/module/wizard/base_update_translations_view.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="wizard_update_translations" model="ir.ui.view"> + <field name="name">Synchronize Translations</field> + <field name="model">base.update.translations</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Synchronize Translations"> + <group col="8"> + <group colspan="3"> + <field name="config_logo" widget="image" width="220" height="130" nolabel="1" colspan="1"/> + <newline/> + <label colspan="4" width="220" string="This wizard will detect new terms to translate in the application, so that you can then add translations manually or perform a complete export (as a template for a new language example)."/> + </group> + <separator orientation="vertical" rowspan="15"/> + <group colspan="4"> + <separator string="Synchronize Translation" colspan="4"/> + <field name="lang" colspan="4"/> + </group> + <group colspan="8" col="8"> + <separator string="" colspan="8"/> + <label colspan="6" width="220"/> + <button icon="gtk-cancel" name="act_cancel" special="cancel" string="Cancel" type="object"/> + <button icon="gtk-ok" name="act_update" string="Update" type="object"/> + </group> + </group> + </form> + </field> + </record> + <record id="action_wizard_update_translations" model="ir.actions.act_window"> + <field name="name">Synchronize Translations</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">base.update.translations</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + <menuitem action="action_wizard_update_translations" id="menu_wizard_update_translations" parent="menu_translation_app"/> + + </data> +</openerp> diff --git a/bin/addons/base/module/wizard/wizard_configuration.py b/bin/addons/base/module/wizard/wizard_configuration.py deleted file mode 100644 index e720ba419b0..00000000000 --- a/bin/addons/base/module/wizard/wizard_configuration.py +++ /dev/null @@ -1,42 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -############################################################################## - -import wizard -import pooler - -class wizard_configuration(wizard.interface): - - def _config(self, cr, uid, data, context=None): - return pooler.get_pool(cr.dbname).get('res.config')\ - .next(cr, uid, [], context=context) - - states = { - 'init':{ - 'result': { - 'type': 'action', - 'action': _config, - 'state': 'end', - }, - } - } -wizard_configuration('module.configuration') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/bin/addons/base/module/wizard/wizard_import_lang.py b/bin/addons/base/module/wizard/wizard_import_lang.py deleted file mode 100644 index 70f94a68f98..00000000000 --- a/bin/addons/base/module/wizard/wizard_import_lang.py +++ /dev/null @@ -1,85 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -############################################################################## - -import wizard -import tools -import base64 -import pooler -from tempfile import TemporaryFile - -view_form="""<?xml version="1.0"?> -<form string="Import language"> - <image name="gtk-dialog-info" colspan="2"/> - <group colspan="2" col="4"> - <separator string="Import New Language" colspan="4"/> - <field name="name" width="200"/> - <field name="code"/> - <field name="data" colspan="4"/> - <label string="You have to import a .CSV file wich is encoded in UTF-8.\n -Please check that the first line of your file is one of the following:" colspan="4" align="0.0"/> - <label string="type,name,res_id,src,value" colspan="4"/> - <label string="module,type,name,res_id,src,value" colspan="4"/> - <label string="You can also import .po files." colspan="4" align="0.0"/> - </group> -</form>""" - -fields_form={ - 'name':{'string':'Language name', 'type':'char', 'size':64, 'required':True}, - 'code':{'string':'Code (eg:en__US)', 'type':'char', 'size':5, 'required':True}, - 'data':{'string':'File', 'type':'binary', 'required':True}, -} - -class wizard_import_lang(wizard.interface): - - def _import_lang(self, cr, uid, data, context): - form=data['form'] - fileobj = TemporaryFile('w+') - fileobj.write( base64.decodestring(form['data']) ) - - # now we determine the file format - fileobj.seek(0) - first_line = fileobj.readline().strip().replace('"', '').replace(' ', '') - fileformat = first_line.endswith("type,name,res_id,src,value") and 'csv' or 'po' - fileobj.seek(0) - - tools.trans_load_data(cr.dbname, fileobj, fileformat, form['code'], lang_name=form['name']) - fileobj.close() - return {} - - states={ - 'init':{ - 'actions': [], - 'result': {'type': 'form', 'arch': view_form, 'fields': fields_form, - 'state':[ - ('end', 'Cancel', 'gtk-cancel'), - ('finish', 'Ok', 'gtk-ok', True) - ] - } - }, - 'finish':{ - 'actions':[], - 'result':{'type':'action', 'action':_import_lang, 'state':'end'} - }, - } -wizard_import_lang('module.lang.import') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/bin/addons/base/module/wizard/wizard_module_import.py b/bin/addons/base/module/wizard/wizard_module_import.py deleted file mode 100644 index 1350a4ad0ba..00000000000 --- a/bin/addons/base/module/wizard/wizard_module_import.py +++ /dev/null @@ -1,118 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -############################################################################## - - -import wizard -import osv -import pooler -import os -import tools - -import zipfile -from StringIO import StringIO -import base64 -from tools.translate import _ - -finish_form ='''<?xml version="1.0"?> -<form string="Module import"> - <label string="Module successfully imported !" colspan="4"/> -</form> -''' - -ask_form ='''<?xml version="1.0"?> -<form string="Module import"> - <separator string="Module Import" colspan="4"/> - <label string="Please give your module .ZIP file to import." colspan="4"/> - <field name="module_file"/> -</form> -''' - -ask_fields = { - 'module_file': {'string': 'Module .ZIP file', 'type': 'binary', 'required': True}, -} - -class move_module_wizard(wizard.interface): - def importzip(self, cr, uid, data, context): - module_obj=pooler.get_pool(cr.dbname).get('ir.module.module') - module_data = data['form']['module_file'] - - val =base64.decodestring(module_data) - fp = StringIO() - fp.write(val) - fdata = zipfile.ZipFile(fp, 'r') - fname = fdata.namelist()[0] - module_name = os.path.split(fname)[0] - - ad = tools.config['addons_path'] - - fname = os.path.join(ad,module_name+'.zip') - try: - fp = file(fname, 'wb') - fp.write(val) - fp.close() - except IOError, e: - raise wizard.except_wizard(_('Error !'), _('Can not create the module file: %s !') % (fname,) ) - - pooler.get_pool(cr.dbname).get('ir.module.module').update_list(cr, uid) - return {'module_name': module_name} - - def _action_module_open(self, cr, uid, data, context): - return { - 'domain': str([('name', '=', data['form']['module_name'])]), - 'name': 'Module List', - 'view_type': 'form', - 'view_mode': 'tree,form', - 'res_model': 'ir.module.module', - 'view_id': False, - 'type': 'ir.actions.act_window' - } - - states = { - 'init': { - 'actions': [], - 'result': { - 'type': 'form', - 'arch': ask_form, - 'fields': ask_fields, - 'state': [ - ('end', 'Cancel', 'gtk-cancel'), - ('import', 'Import module', 'gtk-ok', True) - ] - } - }, - 'import': { - 'actions': [importzip], - 'result': { - 'type':'form', - 'arch':finish_form, - 'fields':{}, - 'state':[('open_window','Close')] - } - }, - 'open_window': { - 'actions': [], - 'result': {'type': 'action', 'action': _action_module_open, 'state':'end'} - }, - } -move_module_wizard('base.module.import') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/bin/addons/base/module/wizard/wizard_module_lang_install.py b/bin/addons/base/module/wizard/wizard_module_lang_install.py deleted file mode 100644 index 7367bdb4baa..00000000000 --- a/bin/addons/base/module/wizard/wizard_module_lang_install.py +++ /dev/null @@ -1,84 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -############################################################################## - -import wizard -import tools -import pooler - -view_form_end = """<?xml version="1.0"?> -<form string="Language file loaded."> - <image name="gtk-dialog-info" colspan="2"/> - <group colspan="2" col="4"> - <separator string="Installation Done" colspan="4"/> - <label align="0.0" string="The selected language has been successfully installed.\nYou must change the preferences of the user and open a new menu to view changes." colspan="4"/> - </group> -</form>""" - -view_form = """<?xml version="1.0"?> -<form string="System Upgrade"> - <image name="gtk-dialog-info" colspan="2"/> - <group colspan="2" col="4"> - <separator string="System Upgrade" colspan="4"/> - <label align="0.0" string="Choose a language to install:" colspan="4"/> - <field name="lang" colspan="4" required="1"/> - <label align="0.0" string="Note that this operation may take a few minutes." colspan="4"/> - </group> -</form>""" - - -class wizard_lang_install(wizard.interface): - def _lang_install(self, cr, uid, data, context): - lang = data['form']['lang'] - if lang: - modobj = pooler.get_pool(cr.dbname).get('ir.module.module') - mids = modobj.search(cr, uid, [('state', '=', 'installed')]) - modobj.update_translations(cr, uid, mids, lang) - return {} - - fields_form = { - 'lang': {'string':'Language', 'type':'selection', 'selection':tools.scan_languages(), - }, - } - - states = { - 'init': { - 'actions': [], - 'result': {'type': 'form', 'arch': view_form, 'fields': fields_form, - 'state': [ - ('end', 'Cancel', 'gtk-cancel'), - ('start', 'Start installation', 'gtk-ok', True) - ] - } - }, - 'start': { - 'actions': [_lang_install], - 'result': {'type': 'form', 'arch': view_form_end, 'fields': {}, - 'state': [ - ('end', 'Ok', 'gtk-ok', True) - ] - } - }, - } -wizard_lang_install('module.lang.install') - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/bin/addons/base/module/wizard/wizard_module_upgrade.py b/bin/addons/base/module/wizard/wizard_module_upgrade.py deleted file mode 100644 index 04be1c1428d..00000000000 --- a/bin/addons/base/module/wizard/wizard_module_upgrade.py +++ /dev/null @@ -1,219 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -############################################################################## - -import wizard -import pooler -import os -import tools - -view_form_end = """<?xml version="1.0"?> -<form string="System update done"> - <separator string="System update completed"/> - <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"/> -</form>""" - -view_form = """<?xml version="1.0"?> -<form string="System Update"> - <image name="gtk-dialog-info" colspan="2"/> - <group colspan="2" col="4"> - <label align="0.0" string="Your system will be updated." colspan="4"/> - <label align="0.0" string="Note that this operation might take a few minutes." colspan="4"/> - <separator string="Modules to update"/> - <field name="module_info" nolabel="1" colspan="4"/> - </group> -</form>""" - -view_field = { - "module_info": {'type': 'text', 'string': 'Modules to update', 'readonly': True}, -} - -class wizard_info_get(wizard.interface): - def _get_install(self, cr, uid, data, context): - pool=pooler.get_pool(cr.dbname) - mod_obj = pool.get('ir.module.module') - ids = mod_obj.search(cr, uid, [ - ('state', 'in', ['to upgrade', 'to remove', 'to install'])]) - res = mod_obj.read(cr, uid, ids, ['name','state'], context) - return {'module_info': '\n'.join(map(lambda x: x['name']+' : '+x['state'], res))} - - def _check_upgrade_module(self,cr,uid,data,context): - pool = pooler.get_pool(cr.dbname) - mod_obj = pool.get('ir.module.module') - ids = mod_obj.search(cr, uid, [ - ('state', 'in', ['to upgrade', 'to remove', 'to install'])]) - if ids and len(ids): - return 'next' - else: - return 'end' - - def _upgrade_module(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - 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) - return {} - - def _config(self, cr, uid, data, context=None): - return pooler.get_pool(cr.dbname).get('res.config')\ - .next(cr, uid, [], context=context) - - states = { - 'init': { - 'actions': [], - 'result' : {'type': 'choice', 'next_state': _check_upgrade_module } - }, - 'next': { - 'actions': [_get_install], - 'result': {'type':'form', 'arch':view_form, 'fields': view_field, - 'state':[ - ('end', 'Cancel', 'gtk-cancel'), - ('start', 'Start update', 'gtk-ok', True) - ] - } - }, - 'start': { - 'actions': [_upgrade_module], - 'result': {'type':'form', 'arch':view_form_end, 'fields': {}, - 'state':[ - ('end', 'Close', 'gtk-close', True), - ('config', 'Start configuration', 'gtk-ok', True) - ] - } - }, - 'end': { - 'actions': [], - 'result': {'type':'form', 'arch':view_form_end, 'fields': {}, - 'state':[ - ('end', 'Close', 'gtk-close', True), - ('config', 'Start configuration', 'gtk-ok', True) - ] - } - }, - 'config':{ - 'result': { - 'type': 'action', - 'action': _config, - 'state': 'end', - }, - } - } -wizard_info_get('module.upgrade') - - -class wizard_info_get_simple(wizard.interface): - def _get_install(self, cr, uid, data, context): - pool=pooler.get_pool(cr.dbname) - mod_obj = pool.get('ir.module.module') - ids = mod_obj.search(cr, uid, [ - ('state', 'in', ['to upgrade', 'to remove', 'to install'])]) - res = mod_obj.read(cr, uid, ids, ['name','state'], context) - return {'module_info': '\n'.join(map(lambda x: x['name']+' : '+x['state'], res)),} - - def _check_upgrade_module(self,cr,uid,data,context): - pool = pooler.get_pool(cr.dbname) - mod_obj = pool.get('ir.module.module') - ids = mod_obj.search(cr, uid, [ - ('state', 'in', ['to upgrade', 'to remove', 'to install'])]) - if ids and len(ids): - return 'next' - else: - return 'end' - - def _upgrade_module(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - 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 dependencies!', 'The following modules are not installed or unavailable. \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) - return {} - - def _config(self, cr, uid, data, context=None): - return pooler.get_pool(cr.dbname).get('res.config')\ - .next(cr, uid, [], context=context) - - states = { - 'init': { - 'actions': [], - 'result' : {'type': 'choice', 'next_state': _check_upgrade_module } - }, - 'next': { - 'actions': [_get_install], - 'result': {'type':'form', 'arch':view_form, 'fields': view_field, - 'state':[ - ('end', 'Cancel', 'gtk-cancel'), - ('start', 'Start update', 'gtk-ok', True) - ] - } - }, - 'start': { - 'actions': [_upgrade_module], - 'result': {'type':'form', 'arch':view_form_end, 'fields': {}, - 'state':[ - ('end', 'Close', 'gtk-close', True), - ('config', 'Start configuration', 'gtk-ok', True) - ] - } - }, - 'end': { - 'actions': [], - 'result': {'type':'form', 'arch':view_form_end, 'fields': {}, - 'state':[ - ('end', 'Close', 'gtk-close', True), - ('config', 'Start configuration', 'gtk-ok', True) - ] - } - }, - 'config':{ - 'result': { - 'type': 'action', - 'action': _config, - 'state': 'end', - }, - } - } -wizard_info_get_simple('module.upgrade.simple') - - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/bin/addons/base/module/wizard/wizard_update_module.py b/bin/addons/base/module/wizard/wizard_update_module.py deleted file mode 100644 index 22e52bb6d6d..00000000000 --- a/bin/addons/base/module/wizard/wizard_update_module.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -############################################################################## - -import wizard -import netsvc -import pooler - -class wizard_update_module(wizard.interface): - - arch = '''<?xml version="1.0"?> - <form string="Scan for new modules"> - <label string="This function will check for new modules in the 'addons' path" colspan="4" align="0.0"/> - - </form>''' - fields = { - - } - - arch_module = '''<?xml version="1.0"?> - <form string="New modules"> - <field name="update" colspan="4"/> - <field name="add" colspan="4"/> - </form>''' - - fields_module = { - 'update': {'type': 'integer', 'string': 'Number of modules updated', 'readonly': True}, - 'add': {'type': 'integer', 'string': 'Number of modules added', 'readonly': True}, - } - - def _update_module(self, cr, uid, data, context): - update, add = pooler.get_pool(cr.dbname).get('ir.module.module').update_list(cr, uid) - return {'update': update, 'add': add} - - def _action_module_open(self, cr, uid, data, context): - - res = { - 'domain': str([]), - 'name': 'Module List', - 'view_type': 'form', - 'view_mode': 'tree,form', - 'res_model': 'ir.module.module', - 'view_id': False, - 'type': 'ir.actions.act_window' - } - - search_view_id = pooler.get_pool(cr.dbname).get('ir.ui.view').search(cr, uid, [('name','=','ir.module.module.list.select')], context=context) - if search_view_id: - res.update({'search_view_id' : search_view_id[0]}) - return res - - states = { - 'init': { - 'actions': [], - 'result': {'type': 'form', 'arch': arch, 'fields': fields, - 'state': [ - ('end', 'Cancel', 'gtk-cancel'), - ('update', 'Check new modules', 'gtk-ok', True) - ] - } - }, - 'update': { - 'actions': [_update_module], - 'result': {'type': 'form', 'arch': arch_module, 'fields': fields_module, - 'state': [ - ('open_window', 'Ok', 'gtk-ok', True) - ] - } - }, - 'open_window': { - 'actions': [], - 'result': {'type': 'action', 'action': _action_module_open, 'state':'end'} - } - } -wizard_update_module('module.module.update') - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - |
