[IMP] base: refactor/unify base module wizards

bzr revid: odo@openerp.com-20101004143336-nh0vnvbipt5dvmna
This commit is contained in:
Olivier Dony 2010-10-04 16:33:36 +02:00
parent 4d406ba474
commit cd527b6c9d
15 changed files with 259 additions and 355 deletions

View File

@ -68,6 +68,7 @@ class base_language_export(osv.osv_memory):
return self.write(cr, uid, ids, {'state':'get', 'data':out, 'advice':this.advice, 'name':this.name}, context=context)
_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 base_language_export(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'
}
}
_defaults = {
'state': lambda *a: 'choose',
'name': lambda *a: 'lang.tar.gz'
}
base_language_export()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -3,48 +3,50 @@
<data>
<record id="wizard_lang_export" model="ir.ui.view">
<field name="name">Export Translation</field>
<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 Translation">
<group colspan="3">
<group colspan="1">
<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=""/>
<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=""/>
<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"/>
</group>
<group colspan="1">
<separator orientation="vertical" rowspan="15"/>
</group>
<group colspan="1">
<group colspan="4" states="choose">
<separator colspan="4" string="Export Translation"/>
<field name="lang" required="1"/>
<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>
<separator string="" colspan="4"/>
<group colspan="2" col="2">
</group>
<group col="2" colspan="2">
<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="_Export" type="object"></button>
<button icon="gtk-close" name="act_destroy" special="cancel" states="get" string="_Close" type="object"/>
</group>
<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>

View File

@ -21,7 +21,6 @@
import tools
import base64
import pooler
from tempfile import TemporaryFile
from osv import osv, fields
@ -30,6 +29,7 @@ class base_language_import(osv.osv_memory):
_name = "base.language.import"
_description = "Language Import"
_inherit = "ir.wizard.screen"
_columns = {
'name': fields.char('Language Name',size=64 , required=True),

View File

@ -7,35 +7,33 @@
<field name="model">base.language.import</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import Language">
<group colspan="3">
<group colspan="1">
<label string="You have to import a .CSV file which is encoded in UTF-8."/>
<label string="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>
<group colspan="1">
<separator orientation="vertical" rowspan="8"/>
</group>
<group colspan="1">
<group colspan="4" col="4">
<separator string="Import Translation" colspan="4"/>
<field name="name" width="200"/>
<field name="code"/>
<field name="data" colspan="4"/>
<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"/>
<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>
<separator string="" colspan="4"/>
<group colspan="2" col="2">
</group>
<group colspan="2" col="2">
<button special="cancel" string="_Close" icon="gtk-cancel"/>
<button name="import_lang" string="_Import" type="object" icon="gtk-ok"/>
</group>
</group>
</group>
</form>
</form>
</field>
</record>

View File

@ -20,17 +20,22 @@
##############################################################################
import tools
import pooler
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'),
'lang': fields.selection(tools.scan_languages(),'Language', required=True),
'state':fields.selection([('init','init'),('done','done')], 'state', readonly=True),
}
_defaults = {
'state': 'init',
}
def lang_install(self, cr, uid, ids, context):
@ -40,30 +45,9 @@ class base_language_install(osv.osv_memory):
modobj = self.pool.get('ir.module.module')
mids = modobj.search(cr, uid, [('state', '=', 'installed')])
modobj.update_translations(cr, uid, mids, lang)
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'base', 'view_base_language_install_msg')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'base.module.import.msg',
'views': [(id2, 'form')],
'view_id': False,
'type': 'ir.actions.act_window',
'target': 'new',
}
self.write(cr, uid, ids, {'state': 'done'}, context=context)
return False
base_language_install()
class base_language_install_msg(osv.osv_memory):
""" Install Language"""
_name = "base.language.install.msg"
_description = "Install Language"
base_language_install_msg()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -8,13 +8,38 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Load Official Translation">
<separator string="Load an Official Translation" colspan="4"/>
<group colspan="4"><field name="lang"/></group>
<label string="" colspan="4"/>
<label string="Please be patient, as this operation may take a few minutes..." colspan="4"/>
<separator string="" colspan="4"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="lang_install" string="Load" type="object" icon="gtk-ok"/>
<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 Official Translation" colspan="4"/>
<group states="init" colspan="4">
<field name="lang" colspan="4"/>
</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>
@ -33,29 +58,6 @@
action="action_view_base_language_install"
id="menu_view_base_language_install"
parent="menu_translation" sequence="2"/>
<record id="view_base_language_install_msg" model="ir.ui.view">
<field name="name">Official Translation Loaded</field>
<field name="model">base.module.import.msg</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Official Translation Loaded">
<separator string="Official Translation Loaded" colspan="4"/>
<label string="The selected language has been successfully installed.\nYou must change the preferences of the user and open a new menu to view the changes." colspan="4"/>
<separator string="" colspan="4"/>
<button special="cancel" string="OK" icon="gtk-ok"/>
</form>
</field>
</record>
<record id="action_view_base_language_install_msg" model="ir.actions.act_window">
<field name="name">Official Translation Loaded</field>
<field name="res_model">base.module.import.msg</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_base_language_install"/>
<field name="target">new</field>
</record>
</data>
</openerp>

View File

@ -19,8 +19,6 @@
#
##############################################################################
import pooler
import os
import tools
@ -34,19 +32,24 @@ 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):
module_obj= self.pool.get('ir.module.module')
active_ids = context and context.get('active_ids', False)
data = self.browse(cr, uid, ids , context=context)[0]
(data,) = self.browse(cr, uid, ids , context=context)
module_data = data.module_file
val =base64.decodestring(module_data)
val = base64.decodestring(module_data)
fp = StringIO()
fp.write(val)
fdata = zipfile.ZipFile(fp, 'r')
@ -55,62 +58,30 @@ class base_module_import(osv.osv_memory):
ad = tools.config['addons_path']
fname = os.path.join(ad,module_name+'.zip')
fname = os.path.join(ad, module_name+'.zip')
try:
fp = file(fname, 'wb')
fp.write(val)
fp.close()
except IOError, e:
except IOError:
raise osv.except_osv(_('Error !'), _('Can not create the module file: %s !') % (fname,) )
module_obj.update_list(cr, uid,{'module_name': module_name,})
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'base', 'view_base_module_import_msg')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
module_name = module_obj.browse(cr, uid, ids, context=context)
return {
'domain': str([('name', '=', module_name)]),
'name': 'Message',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'base.module.import.msg',
'views': [(id2, 'form')],
'view_id': False,
'type': 'ir.actions.act_window',
'target': 'new',
}
base_module_import()
class base_module_import_msg(osv.osv_memory):
""" message """
_name = "base.module.import.msg"
_description = "Message"
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):
module_obj = self.pool.get('base.module.import')
data = module_obj.browse(cr, uid, ids , context=context)[0]
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]
(data,) = self.browse(cr, uid, ids , context=context)
return {
'domain': str([('name', '=', module_name)]),
'name': 'Module List',
'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_msg()
base_module_import()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -7,17 +7,41 @@
<field name="model">base.module.import</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import module">
<separator string="Module Import" colspan="4"/>
<label string="Please give your module .ZIP file to import." colspan="4"/>
<field name="module_file"/>
<separator string="" colspan="4" />
<newline/>
<group colspan="6" >
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="importzip" string="Import module" type="object" icon="gtk-ok"/>
</group>
</form>
<form string="Import module">
<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 you 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="Module Import" colspan="4"/>
<group states="init" colspan="4" col="4">
<label string="Select module package to import (.zip file):" colspan="4"/>
<field name="module_file" colspan="4"/>
</group>
<group states="done" colspan="4" 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>
@ -31,36 +55,12 @@
</record>
<menuitem
name="Import Module"
action="action_view_base_module_import"
id="menu_view_base_module_import"
parent="menu_management"
sequence="1"/>
name="Import Module"
action="action_view_base_module_import"
id="menu_view_base_module_import"
parent="menu_management"
sequence="1"/>
<record id="view_base_module_import_msg" model="ir.ui.view">
<field name="name">Module Import Message</field>
<field name="model">base.module.import.msg</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Message">
<label string="Module successfully imported !"/>
<separator string="" colspan="4"/>
<newline/>
<group>
<button name="action_module_open" string="Cancel" type="object" icon="gtk-cancel"/>
</group>
</form>
</field>
</record>
<record id="action_view_base_module_import_msg" model="ir.actions.act_window">
<field name="name">Module Import Message</field>
<field name="res_model">base.module.import.msg</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_base_module_import"/>
<field name="target">new</field>
</record>
</data>
</openerp>

View File

@ -19,16 +19,13 @@
#
##############################################################################
import os
import re
import glob
import time
import imp
import tools
import pooler
import zipfile
from osv import osv, fields
from osv import osv
class base_module_scan(osv.osv_memory):
""" scan module """

View File

@ -18,8 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import netsvc
import pooler
from osv import osv, fields
class base_module_update(osv.osv_memory):
@ -27,69 +25,25 @@ class base_module_update(osv.osv_memory):
_name = "base.module.update"
_description = "Update Module"
def update_module(self, cr, uid, ids, context):
"""
Update Module
@param cr: the current row, from the database cursor.
@param uid: the current users ID for security checks.
@param ids: the ID or list of IDs
@param context: A standard dictionary
"""
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'base', 'view_base_module_update_open')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'base.module.update.open',
'views': [(id2, 'form')],
'view_id': False,
'type': 'ir.actions.act_window',
'target': 'new',
}
base_module_update()
class base_module_update_open(osv.osv_memory):
""" Update Module Open """
_name = "base.module.update.open"
_description = "Update Module Open"
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param fields: List of fields for default value
@param context: A standard dictionary for contextual values
@return : default values of fields.
"""
module_obj = self.pool.get('ir.module.module')
update, add = module_obj.update_list(cr, uid,)
return {'update': update, 'add': add}
_inherit = "ir.wizard.screen"
_columns = {
'update': fields.integer('Number of modules updated', readonly=True),
'add': fields.integer('Number of modules added', readonly=True),
'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),
}
def action_module_open(self, cr, uid, ids, context):
"""
Update Module List Open
_defaults = {
'state': 'init',
}
@param cr: the current row, from the database cursor.
@param uid: the current users ID for security checks.
@param ids: the ID or list of IDs
@param context: A standard dictionary
"""
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',
@ -99,13 +53,9 @@ class base_module_update_open(osv.osv_memory):
'view_id': False,
'type': 'ir.actions.act_window',
}
view_obj = self.pool.get('ir.ui.view')
search_view_id = view_obj.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
base_module_update_open()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
base_module_update()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -7,15 +7,41 @@
<field name="model">base.module.update</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Scan for new modules">
<label string="This wizard will scan all module repositories (on the server side) to detect any new or updated modules. Please be patient as this operation may take a few seconds..." colspan="4" align="0.0"/>
<separator string="" colspan="4" />
<newline/>
<group colspan="6" >
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="update_module" string="Check new modules" type="object" icon="gtk-ok"/>
</group>
</form>
<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>
@ -36,33 +62,5 @@
sequence="2"
icon="STOCK_CONVERT"/>
<record id="view_base_module_update_open" model="ir.ui.view">
<field name="name">Update ModuleList</field>
<field name="model">base.module.update.open</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="New modules">
<field name="update" colspan="4"/>
<field name="add" colspan="4"/>
<separator string="" colspan="4" />
<newline/>
<group colspan="6" >
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="action_module_open" string="OK" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_view_base_module_update_open" model="ir.actions.act_window">
<field name="name">Update ModuleList</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">base.module.update.open</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_base_module_update"/>
<field name="target">new</field>
</record>
</data>
</openerp>

View File

@ -20,8 +20,6 @@
##############################################################################
import pooler
import os
import tools
from osv import osv, fields
class base_module_upgrade(osv.osv_memory):
@ -98,7 +96,7 @@ class base_module_upgrade(osv.osv_memory):
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()
db, pool = pooler.restart_pool(cr.dbname, update_module=True)
_, pool = pooler.restart_pool(cr.dbname, update_module=True)
id2 = data_obj._get_id(cr, uid, 'base', 'view_base_module_upgrade_install')
if id2:

View File

@ -35,7 +35,7 @@ class base_update_translations(osv.osv_memory):
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):
@ -51,14 +51,17 @@ class base_update_translations(osv.osv_memory):
return {'type': 'ir.actions.act_window_close'}
def default_get(self, cr, uid, fields, context=None):
lang_obj = self.pool.get('res.lang')
res = super(base_update_translations, self).default_get(cr, uid, fields, context=context)
record_id = context and context.get('active_id', False) or False
lang=lang_obj.browse(cr,uid,record_id).code
return {'lang':lang}
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),
}
base_update_translations()
base_update_translations()

View File

@ -2,23 +2,34 @@
<openerp>
<data>
<record id="wizard_update_translations" model="ir.ui.view">
<field name="name">Update Translations</field>
<field name="name">Synchronize 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="Cancel" type="object"/>
<button icon="gtk-ok" name="act_update" string="Update" type="object"/>
<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">Resynchronise Terms</field>
<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>

View File

@ -19,19 +19,14 @@
#
##############################################################################
import os
import base64
import random
from operator import attrgetter
from osv import osv, fields
import tools
from tools.translate import _
import netsvc
import pooler
class res_config_configurable(osv.osv_memory):
''' Base classes for new-style configuration items
@ -40,6 +35,7 @@ class res_config_configurable(osv.osv_memory):
their view inherit from the related res_config_view_base view.
'''
_name = 'res.config'
_inherit = 'ir.wizard.screen'
logger = netsvc.Logger()
def get_current_progress(self, cr, uid, context=None):
@ -57,20 +53,13 @@ class res_config_configurable(osv.osv_memory):
return round(closed*100./total)
return 100.
def _get_image(self, cr, uid, context=None):
file_no = str(random.randint(1,3))
path = os.path.join('base','res','config_pixmaps/%s.png'%file_no)
file_data = tools.file_open(path,'rb').read()
return base64.encodestring(file_data)
_columns = dict(
progress = fields.float('Configuration Progress', readonly=True),
config_logo = fields.binary('Image', readonly=True),
)
)
_defaults = dict(
progress = _progress,
config_logo = _get_image
)
)
def _next_action(self, cr, uid, context=None):
todos = self.pool.get('ir.actions.todo')