[FIX] ir.translation: ensure consistent return type for _get_source(), pending proper fix
lp bug: https://launchpad.net/bugs/613721 fixed bzr revid: odo@openerp.com-20100908170409-3k7tfolwgn599334
This commit is contained in:
@@ -132,11 +132,25 @@ class ir_translation(osv.osv):
|
||||
|
||||
@tools.cache(skiparg=3)
|
||||
def _get_source(self, cr, uid, name, tt, lang, source=None):
|
||||
"""
|
||||
Returns the translation for the given combination of name, type, language
|
||||
and source. All values passed to this method should be unicode (not byte strings),
|
||||
especially ``source``.
|
||||
|
||||
:param name: identification of the term to translate, such as field name
|
||||
:param type: type of term to translate (see ``type`` field on ir.translation)
|
||||
:param lang: language code of the desired translation
|
||||
:param source: optional source term to translate (should be unicode)
|
||||
:rtype: unicode
|
||||
:return: the request translation, or an empty unicode string if no translation was
|
||||
found and `source` was not passed
|
||||
"""
|
||||
# FIXME: should assert that `source` is unicode and fix all callers to always pass unicode
|
||||
# so we can remove the string encoding/decoding.
|
||||
|
||||
if not lang:
|
||||
return ''
|
||||
return u''
|
||||
if source:
|
||||
#if isinstance(source, unicode):
|
||||
# source = source.encode('utf8')
|
||||
cr.execute('select value ' \
|
||||
'from ir_translation ' \
|
||||
'where lang=%s ' \
|
||||
@@ -152,9 +166,9 @@ class ir_translation(osv.osv):
|
||||
'and name=%s',
|
||||
(lang or '', tt, tools.ustr(name)))
|
||||
res = cr.fetchone()
|
||||
trad = res and res[0] or ''
|
||||
trad = res and res[0] or u''
|
||||
if source and not trad:
|
||||
return source
|
||||
return tools.ustr(source)
|
||||
return trad
|
||||
|
||||
def create(self, cursor, user, vals, context=None):
|
||||
|
||||
Reference in New Issue
Block a user