[MERGE]: Merge with lp:~openerp-dev/openobject-server/ksa-dev-framework for osv_memory wizards

bzr revid: rpa@tinyerp.com-20100903053927-xvr7ourv9rgmvt4t
This commit is contained in:
rpa (Open ERP)
2010-09-03 11:09:27 +05:30
18 changed files with 442 additions and 444 deletions
+5 -1
View File
@@ -43,7 +43,6 @@
'ir/wizard/wizard_menu_view.xml',
'ir/ir.xml',
'ir/workflow/workflow_view.xml',
'module/module_wizard.xml',
'module/module_view.xml',
'module/module_web_view.xml',
'module/module_data.xml',
@@ -51,6 +50,11 @@
'module/wizard/base_module_import_view.xml',
'module/wizard/base_module_update_view.xml',
'module/wizard/base_language_install_view.xml',
'module/wizard/base_import_language_view.xml',
'module/wizard/base_module_upgrade_view.xml',
'module/wizard/base_module_configuration_view.xml',
'module/wizard/base_export_language_view.xml',
'module/wizard/base_update_translations_view.xml',
'res/res_request_view.xml',
'res/res_lang_view.xml',
'res/res_log_view.xml',
+15 -23
View File
@@ -23,7 +23,7 @@
</form>
</field>
</record>
<record id="values_view_tree_action" model="ir.ui.view">
<field name="name">ir.values.tree.action</field>
<field name="model">ir.values</field>
@@ -37,7 +37,7 @@
</tree>
</field>
</record>
<record id="values_view_search_action" model="ir.ui.view">
<field name="name">ir.values.search.action</field>
<field name="model">ir.values</field>
@@ -50,7 +50,7 @@
</search>
</field>
</record>
<record id="act_values_form_action" model="ir.actions.act_window">
<field name="name">Client Actions</field>
<field name="type">ir.actions.act_window</field>
@@ -61,14 +61,14 @@
<field name="domain">[('key','=','action')]</field>
<field name="context">{'read':'default','default_object':1}</field>
</record>
<record model="ir.actions.act_window.view" id="action_values_tree_view">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="values_view_tree_action"/>
<field name="act_window_id" ref="act_values_form_action"/>
</record>
<record model="ir.actions.act_window.view" id="action_values_form_view">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
@@ -353,7 +353,7 @@
</tree>
</field>
</record>
<!--Filters search view-->
<record id="ir_filters_view_search" model="ir.ui.view">
@@ -628,7 +628,7 @@
</search>
</field>
</record>
<record id="ir_action_window" model="ir.actions.act_window">
<field name="name">Window Actions</field>
<field name="type">ir.actions.act_window</field>
@@ -681,7 +681,7 @@
</form>
</field>
</record>
<record id="act_wizard_search_view" model="ir.ui.view">
<field name="name">ir.actions.wizard.search</field>
<field name="model">ir.actions.wizard</field>
@@ -694,7 +694,7 @@
</search>
</field>
</record>
<record id="ir_action_wizard" model="ir.actions.act_window">
<field name="name">Wizards</field>
<field name="type">ir.actions.act_window</field>
@@ -831,7 +831,7 @@
</search>
</field>
</record>
<record id="action_res_roles" model="ir.actions.act_window">
<field name="name">Roles Structure</field>
<field name="type">ir.actions.act_window</field>
@@ -1297,7 +1297,7 @@
</search>
</field>
</record>
<record model="ir.ui.view" id="view_model_data_form">
<field name="name">ir.model.data.form</field>
<field name="model">ir.model.data</field>
@@ -1510,7 +1510,7 @@
</form>
</field>
</record>
<record id="edit_menu_access_search" model="ir.ui.view">
<field name="name">ir.ui.menu.search</field>
<field name="model">ir.ui.menu</field>
@@ -1522,7 +1522,7 @@
</search>
</field>
</record>
<record id="grant_menu_access" model="ir.actions.act_window">
<field name="name">Manage Menus</field>
<field name="res_model">ir.ui.menu</field>
@@ -1676,7 +1676,7 @@
</search>
</field>
</record>
<record id="ir_access_act" model="ir.actions.act_window">
<field name="name">Access Controls List</field>
<field name="res_model">ir.model.access</field>
@@ -1868,7 +1868,7 @@
</tree>
</field>
</record>
<record id="view_server_action_search" model="ir.ui.view">
<field name="name">ir.actions.server.search</field>
<field name="model">ir.actions.server</field>
@@ -1973,13 +1973,5 @@
</record>
<menuitem id="next_id_11" name="Configuration Wizards" parent="base.menu_config" sequence="1"/>
<wizard id="wizard_configuration" model="ir.module.module" name="module.configuration" string="Start Configuration"/>
<menuitem action="act_ir_actions_todo_form" id="menu_ir_actions_todo_form"
parent="next_id_11" groups="base.group_extended" sequence="20"/>
<menuitem
action="wizard_configuration" name="Start Configuration"
id="menu_configurator_module" parent="next_id_11"
type="wizard"/>
</data>
</openerp>
+5 -7
View File
@@ -19,16 +19,14 @@
#
##############################################################################
import wizard_module_upgrade
import wizard_configuration
import add_new
import wizard_export_lang
import wizard_import_lang
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:
@@ -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/>.
#
##############################################################################
@@ -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_export_language(osv.osv_memory):
def _get_languages(self, cr, uid, context):
lang_obj=pooler.get_pool(cr.dbname).get('res.lang')
@@ -67,7 +67,7 @@ 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.export.language"
_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
@@ -82,7 +82,7 @@ class wizard_export_lang(osv.osv_memory):
_defaults = { 'state': lambda *a: 'choose',
'name': lambda *a: 'lang.tar.gz'
}
wizard_export_lang()
base_export_language()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -2,13 +2,9 @@
<openerp>
<data>
<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_export" model="ir.ui.view">
<field name="name">Export a Translation File</field>
<field name="model">wizard.module.lang.export</field>
<field name="model">base.export.language</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form col="3" string="Export language">
@@ -38,7 +34,7 @@
<group col="2" colspan="3" fill="0">
<button icon="gtk-cancel" name="act_cancel" special="cancel" states="choose" string="Close" type="object"/>
<button icon="gtk-ok" name="act_getfile" states="choose" string="Get file" type="object"/>
<button icon="gtk-ok" name="act_getfile" states="choose" string="Get file" type="object"></button>
<button icon="gtk-close" name="act_destroy" special="cancel" states="get" string="Close" type="object"/>
</group>
</form>
@@ -48,44 +44,11 @@
<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="res_model">base.export.language</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">
<field name="lang"/>
<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="Close" 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>
@@ -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
import pooler
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"
_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()
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_base_import_language" model="ir.ui.view">
<field name="name">Import Language</field>
<field name="model">base.language.import</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import language">
<notebook colspan="4">
<page string="Import Data">
<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"/>
</group>
</page>
<page string="Help">
<label string="You have to import a .CSV file which 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"/>
</page>
</notebook>
<newline/>
<group colspan="6" >
<button special="cancel" string="Close" icon="gtk-cancel"/>
<button name="import_lang" string="OK" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_view_base_import_language" model="ir.actions.act_window">
<field name="name">Import Language</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
name="Import a Translation File"
action="action_view_base_import_language"
id="menu_view_base_import_language"
parent="menu_translation_export"/>
</data>
</openerp>
@@ -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,28 +15,20 @@
# 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
import pooler
from osv import osv, fields
class wizard_configuration(wizard.interface):
class base_module_configuration(osv.osv_memory):
def _config(self, cr, uid, data, context=None):
return pooler.get_pool(cr.dbname).get('res.config')\
.next(cr, uid, [], context=context)
_name = "base.module.configuration"
def config(self, cr, uid, data, context=None):
return self.pool.get('res.config').next(cr, uid, [], context=context)
base_module_configuration()
states = {
'init':{
'result': {
'type': 'action',
'action': _config,
'state': 'end',
},
}
}
wizard_configuration('module.configuration')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_base_module_configuration" 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="">
</form>
</field>
</record>
<record id="action_view_base_module_configuration" model="ir.actions.act_window">
<field name="name">Module Configuration</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">base.module.configuration</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
name="Start Configuration"
action="action_view_base_module_configuration"
id="menu_view_base_module_configuration"
parent="next_id_11"
sequence="2"/>
<act_window id="action_view_base_module_configuration_window"
key2="client_action_multi" name="Start Configuration"
res_model="base.module.configuration" src_model="ir.module.module"
view_mode="form" target="new" view_type="form" />
</data>
</openerp>
@@ -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,10 +15,9 @@
# 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
@@ -27,23 +25,19 @@ import time
import imp
import tools
import wizard
import pooler
import zipfile
from osv import osv, fields
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 +73,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()
@@ -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>
@@ -0,0 +1,89 @@
# -*- 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
import os
import tools
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 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')
data_obj = self.pool.get('ir.model.data')
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 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 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)
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()
@@ -0,0 +1,73 @@
<?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="Close" 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="arch" type="xml">
<form string="System update done">
<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>
</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>
@@ -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,13 +24,13 @@ 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)])
@@ -50,9 +50,9 @@ class update_translations(osv.osv_memory):
buf.close()
return {'type': 'ir.actions.act_window_close'}
_name = 'wizard.module.update_translations'
_name = 'base.update.translations'
_columns = {
'lang': fields.selection(_get_languages, 'Language', required=True),
}
update_translations()
base_update_translations()
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="wizard_update_translations" model="ir.ui.view">
<field name="name">Update Translations</field>
<field name="model">base.update.translations</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form col="3" string="Update Translations">
<field name="lang"/>
<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="Close" 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">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>
@@ -1,90 +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">
<notebook colspan="4">
<page string="Import Data">
<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"/>
</group>
</page>
<page string="Help">
<label string="You have to import a .CSV file which 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"/>
</page>
</notebook>
</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', 'Close', '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:
@@ -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:
@@ -14,7 +14,7 @@
<field name="mobile_to"/>
<field name="app_id"/>
<field name="user"/>
<field name="password"/>
<field name="password"/>
<separator string="Message" colspan="4" />
<field name="text" colspan="4" nolabel="1"/>
<separator string="" colspan="4" />
@@ -32,7 +32,6 @@
view_mode="form"
target="new"
key2="client_action_multi"
id="action_partner_sms_send"
groups="base.group_extended"/>
id="action_partner_sms_send"/>
</data>
</openerp>