diff --git a/bin/addons/base/ir/ir_model.py b/bin/addons/base/ir/ir_model.py index 15c3224e784..0c6bfc7edb1 100644 --- a/bin/addons/base/ir/ir_model.py +++ b/bin/addons/base/ir/ir_model.py @@ -71,7 +71,7 @@ class ir_model(osv.osv): def unlink(self, cr, user, ids, context=None): for model in self.browse(cr, user, ids, context): if model.state <> 'manual': - raise except_orm('Error', "You can not remove the model '%s' !" %(field.name,)) + raise except_orm(_('Error'), _("You can not remove the model '%s' !") %(field.name,)) res = super(ir_model, self).unlink(cr, user, ids, context) pooler.restart_pool(cr.dbname) return res @@ -138,7 +138,7 @@ class ir_model_fields(osv.osv): def unlink(self, cr, user, ids, context=None): for field in self.browse(cr, user, ids, context): if field.state <> 'manual': - raise except_orm('Error', "You can not remove the field '%s' !" %(field.name,)) + raise except_orm(_('Error'), _("You can not remove the field '%s' !") %(field.name,)) # # MAY BE ADD A ALTER TABLE DROP ? # @@ -153,7 +153,7 @@ class ir_model_fields(osv.osv): res = super(ir_model_fields,self).create(cr, user, vals, context) if vals.get('state','base')=='manual': if not vals['name'].startswith('x_'): - raise except_orm('Error', "Custom fields must have a name that starts with 'x_' !") + raise except_orm(_('Error'), _("Custom fields must have a name that starts with 'x_' !")) if self.pool.get(vals['model']): self.pool.get(vals['model']).__init__(self.pool, cr) self.pool.get(vals['model'])._auto_init(cr,{}) @@ -207,7 +207,7 @@ class ir_model_access(osv.osv): 'WHERE a.group_id IS NULL AND m.model = %s', (model_name,)) r= cr.fetchall() if r[0][0] == None: - return True + return False # by default, the user had no access if not r[0][0]: if raise_exception: @@ -282,8 +282,9 @@ class ir_model_data(osv.osv): def _update(self,cr, uid, model, module, values, xml_id=False, store=True, noupdate=False, mode='init', res_id=False): warning = True model_obj = self.pool.get(model) + context = {} if xml_id and ('.' in xml_id): - assert len(xml_id.split('.'))==2, '"%s" contains too many dots. XML ids should not contain dots ! These are used to refer to other modules data, as in module.reference_id' % (xml_id) + assert len(xml_id.split('.'))==2, _('"%s" contains too many dots. XML ids should not contain dots ! These are used to refer to other modules data, as in module.reference_id') % (xml_id) warning = False module, xml_id = xml_id.split('.') if (not xml_id) and (not self.doinit): diff --git a/bin/addons/base/ir/ir_report_custom.py b/bin/addons/base/ir/ir_report_custom.py index b962684035e..af413f54e41 100644 --- a/bin/addons/base/ir/ir_report_custom.py +++ b/bin/addons/base/ir/ir_report_custom.py @@ -31,6 +31,7 @@ from osv import fields,osv from osv.orm import browse_null import ir import report.custom +from tools.translate import _ class report_custom(osv.osv): _name = 'ir.report.custom' @@ -75,10 +76,10 @@ class report_custom(osv.osv): # required on field0 does not seem to work( cause we use o2m_l ?) if not report.fields_child0: - raise osv.except_osv('Invalid operation :', 'Enter at least one field !') + raise osv.except_osv(_('Invalid operation'), _('Enter at least one field !')) if report.type in ['pie', 'bar', 'line'] and report.field_parent: - raise osv.except_osv('Invalid operation :', 'Tree can only be used in tabular reports') + raise osv.except_osv(_('Invalid operation'), _('Tree can only be used in tabular reports')) # Otherwise it won't build a good tree. See level.pop in custom.py. if report.type == 'table' and report.field_parent and report.fields_child0 and not report.fields_child0[0].groupby: @@ -86,7 +87,7 @@ class report_custom(osv.osv): if report.type == 'pie': if len(report.fields_child0) != 2: - raise osv.except_osv('Invalid operation :', 'Pie charts need exactly two fields') + raise osv.except_osv(_('Invalid operation'), _('Pie charts need exactly two fields')) else: c_f = {} for i in range(2): @@ -95,11 +96,11 @@ class report_custom(osv.osv): for j in range(3): c_f[i].append((not isinstance(eval('tmp.field_child'+str(j)), browse_null) and eval('tmp.field_child'+str(j)+'.ttype')) or None) if not reduce(lambda x,y : x or y, map(lambda x: x in ['integer', 'float'], c_f[1])): - raise osv.except_osv('Invalid operation : ','Second field should be figures') + raise osv.except_osv(_('Invalid operation'), _('Second field should be figures')) if report.type == 'bar': if len(report.fields_child0) < 2: - raise osv.except_osv('Invalid operation : ','Bar charts need at least two fields') + raise osv.except_osv(_('Invalid operation'), _('Bar charts need at least two fields')) else: c_f = {} for i in range(len(report.fields_child0)): @@ -112,7 +113,7 @@ class report_custom(osv.osv): pass else: if not reduce(lambda x,y : x or y, map(lambda x: x in ['integer', 'float'], c_f[i])): - raise osv.except_osv('Invalid operation : ','Field %d should be a figure' %(i,)) + raise osv.except_osv(_('Invalid operation'), _('Field %d should be a figure') %(i,)) if report.state=='subscribed': continue @@ -193,7 +194,7 @@ class report_custom_fields(osv.osv): } } else: - print "Warning: using a relation field which uses an unknown object" + print _("Warning: using a relation field which uses an unknown object") #TODO use the logger return {'required': {next_level_field_name: True}} else: return {'domain': {next_level_field_name: []}} diff --git a/bin/addons/base/ir/ir_translation.py b/bin/addons/base/ir/ir_translation.py index 20d2b383405..211f9dbaf45 100644 --- a/bin/addons/base/ir/ir_translation.py +++ b/bin/addons/base/ir/ir_translation.py @@ -121,9 +121,8 @@ class ir_translation(osv.osv, Cacheable): return trans if source: - source = source.strip().replace('\n',' ') - if isinstance(source, unicode): - source = source.encode('utf8') + #if isinstance(source, unicode): + # source = source.encode('utf8') cr.execute('select value ' \ 'from ir_translation ' \ 'where lang=%s ' \ diff --git a/bin/addons/base/ir/ir_values.py b/bin/addons/base/ir/ir_values.py index 8940cc8521b..84fafefa3f4 100644 --- a/bin/addons/base/ir/ir_values.py +++ b/bin/addons/base/ir/ir_values.py @@ -29,6 +29,7 @@ from osv import osv,fields import pickle +from tools.translate import _ class ir_values(osv.osv): _name = 'ir.values' diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py index d124fbc4cdd..8442628a2e3 100644 --- a/bin/addons/base/module/module.py +++ b/bin/addons/base/module/module.py @@ -264,13 +264,13 @@ class module(osv.osv): ids = [ids] for mod in self.read(cr, uid, ids, ['state'], context): if mod['state'] in ('installed', 'to upgrade', 'to remove', 'to install'): - raise orm.except_orm('Error', - 'You try to remove a module that is installed or will be installed') + raise orm.except_orm(_('Error'), + _('You try to remove a module that is installed or will be installed')) return super(module, self).unlink(cr, uid, ids, context=context) def state_change(self, cr, uid, ids, newstate, context={}, level=50): if level<1: - raise Exception, 'Recursion error in modules dependencies !' + raise Exception, _('Recursion error in modules dependencies !') demo = True for module in self.browse(cr, uid, ids): mdemo = True @@ -288,7 +288,7 @@ class module(osv.osv): def state_upgrade(self, cr, uid, ids, newstate, context=None, level=50): dep_obj = self.pool.get('ir.module.module.dependency') if level<1: - raise Exception, 'Recursion error in modules dependencies !' + raise Exception, _('Recursion error in modules dependencies !') for module in self.browse(cr, uid, ids): dep_ids = dep_obj.search(cr, uid, [('name', '=', module.name)]) if dep_ids: @@ -320,7 +320,7 @@ class module(osv.osv): m.state not in ('uninstalled','uninstallable','to remove')''', (module.name,)) res = cr.fetchall() if res: - raise orm.except_orm('Error', 'The module you are trying to remove depends on installed modules :\n' + '\n'.join(map(lambda x: '\t%s: %s' % (x[0], x[1]), res))) + raise orm.except_orm(_('Error'), _('The module you are trying to remove depends on installed modules :\n %s') % '\n'.join(map(lambda x: '\t%s: %s' % (x[0], x[1]), res))) self.write(cr, uid, ids, {'state': 'to remove'}) return True @@ -420,9 +420,8 @@ class module(osv.osv): index_page = urllib.urlopen(repository.url).read() except IOError, e: if e.errno == 21: - raise orm.except_orm('Error', - 'This url \'%s\' must provide an html file ' - 'with links to zip modules' % (repository.url)) + raise orm.except_orm(_('Error'), + _("This url '%s' must provide an html file with links to zip modules") % (repository.url)) else: raise modules = re.findall(repository.filter, index_page, re.I+re.M) @@ -493,8 +492,7 @@ class module(osv.osv): fp.write(zipfile) fp.close() except IOError, e: - raise orm.except_orm('Error', 'Can not create the module file:\n %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, { 'description': terp.get('description', ''), diff --git a/bin/addons/base/module/wizard/wizard_export_lang.py b/bin/addons/base/module/wizard/wizard_export_lang.py index a42e3ec430e..a855ad503c8 100644 --- a/bin/addons/base/module/wizard/wizard_export_lang.py +++ b/bin/addons/base/module/wizard/wizard_export_lang.py @@ -60,12 +60,12 @@ class wizard_export_lang(wizard.interface): lang_obj=pooler.get_pool(cr.dbname).get('res.lang') ids=lang_obj.search(cr, uid, [('active', '=', True),]) langs=lang_obj.browse(cr, uid, ids) - return [(lang.code, lang.translatable and lang.name or 'New language') for lang in langs] + return [(lang.code, lang.translatable and lang.name or _('New language')) for lang in langs] def _get_file(self, cr, uid, data, context): file=tools.trans_generate(data['form']['lang'], 'all', dbname=cr.dbname) buf=StringIO.StringIO() - writer=csv.writer(buf, 'TINY') + writer=csv.writer(buf, 'UNIX') for row in file: writer.writerow(row) del file diff --git a/bin/addons/base/module/wizard/wizard_import_lang.py b/bin/addons/base/module/wizard/wizard_import_lang.py index d9543b7f851..a6516bb24df 100644 --- a/bin/addons/base/module/wizard/wizard_import_lang.py +++ b/bin/addons/base/module/wizard/wizard_import_lang.py @@ -32,6 +32,7 @@ import wizard import tools import base64 import pooler +from tempfile import TemporaryFile view_form="""