Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

原创:odoo导出po翻译文件报错的解决:UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in



  • 卓忆原创:odoo导出po翻译文件报错的解决:UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 1: ordinal not in range(128) 的解决

    在导出po文件的时候 报错,报错全文如下:

    完整的如下:Traceback (most recent call last):
    File "/opt/odoo/odoo-server/openerp/http.py", line 525, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
    File "/opt/odoo/odoo-server/openerp/http.py", line 562, in dispatch
    result = self._call_function(**self.params)
    File "/opt/odoo/odoo-server/openerp/http.py", line 302, in _call_function
    return checked_call(self.db, *args, **kwargs)
    File "/opt/odoo/odoo-server/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
    File "/opt/odoo/odoo-server/openerp/http.py", line 299, in checked_call
    return self.endpoint(*a, **kw)
    File "/opt/odoo/odoo-server/openerp/http.py", line 791, in call
    return self.method(*args, **kw)
    File "/opt/odoo/odoo-server/openerp/http.py", line 395, in response_wrap
    response = f(*args, **kw)
    File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 953, in call_button
    action = self._call_kw(model, method, args, {})
    File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 941, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
    File "/opt/odoo/odoo-server/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
    File "/opt/odoo/odoo-server/openerp/addons/base/module/wizard/base_export_language.py", line 65, in act_getfile
    tools.trans_export(lang, mods, buf, this.format, cr)
    File "/opt/odoo/odoo-server/openerp/tools/translate.py", line 510, in trans_export
    translations = trans_generate(lang, modules, cr)
    File "/opt/odoo/odoo-server/openerp/tools/translate.py", line 875, in trans_generate
    for root, dummy, files in osutil.walksymlinks(path):
    File "/opt/odoo/odoo-server/openerp/tools/osutil.py", line 56, in walksymlinks
    for dirpath, dirnames, filenames in os.walk(top, topdown, onerror):
    File "/usr/lib/python2.7/os.py", line 294, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
    File "/usr/lib/python2.7/os.py", line 284, in walk
    if isdir(join(top, name)):
    File "/usr/lib/python2.7/posixpath.py", line 80, in join
    path += '/' + b
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 1: ordinal not in range(128)
    12:05:36

    经过排查,发现可能是某个第三方模块导致的:

    那个模块只要放在 addons 目录里面,不用安装,导出依然会报错。
    我估计 导出的时候 自动 遍历了整个 addons 目录。
    原因是 这个模块的 xml 文件 最前面少了  encoding="utf-8"?

    正确的应该是 :
    <?xml version="1.0" encoding="utf-8"?>



    谢谢joshua和总监mrshelly。



  • 卓忆原创:odoo导出po翻译文件报错的解决:UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 1: ordinal not in range(128) 的解决

    在导出po文件的时候 报错,报错全文如下:

    完整的如下:Traceback (most recent call last):
    File "/opt/odoo/odoo-server/openerp/http.py", line 525, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
    File "/opt/odoo/odoo-server/openerp/http.py", line 562, in dispatch
    result = self._call_function(**self.params)
    File "/opt/odoo/odoo-server/openerp/http.py", line 302, in _call_function
    return checked_call(self.db, *args, **kwargs)
    File "/opt/odoo/odoo-server/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
    File "/opt/odoo/odoo-server/openerp/http.py", line 299, in checked_call
    return self.endpoint(*a, **kw)
    File "/opt/odoo/odoo-server/openerp/http.py", line 791, in call
    return self.method(*args, **kw)
    File "/opt/odoo/odoo-server/openerp/http.py", line 395, in response_wrap
    response = f(*args, **kw)
    File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 953, in call_button
    action = self._call_kw(model, method, args, {})
    File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 941, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
    File "/opt/odoo/odoo-server/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
    File "/opt/odoo/odoo-server/openerp/addons/base/module/wizard/base_export_language.py", line 65, in act_getfile
    tools.trans_export(lang, mods, buf, this.format, cr)
    File "/opt/odoo/odoo-server/openerp/tools/translate.py", line 510, in trans_export
    translations = trans_generate(lang, modules, cr)
    File "/opt/odoo/odoo-server/openerp/tools/translate.py", line 875, in trans_generate
    for root, dummy, files in osutil.walksymlinks(path):
    File "/opt/odoo/odoo-server/openerp/tools/osutil.py", line 56, in walksymlinks
    for dirpath, dirnames, filenames in os.walk(top, topdown, onerror):
    File "/usr/lib/python2.7/os.py", line 294, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
    File "/usr/lib/python2.7/os.py", line 284, in walk
    if isdir(join(top, name)):
    File "/usr/lib/python2.7/posixpath.py", line 80, in join
    path += '/' + b
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 1: ordinal not in range(128)
    12:05:36

    经过排查,发现可能是某个第三方模块导致的:

    那个模块只要放在 addons 目录里面,不用安装,导出依然会报错。
    我估计 导出的时候 自动 遍历了整个 addons 目录。
    原因是 这个模块的 xml 文件 最前面少了  encoding="utf-8"?

    正确的应该是 :
    <?xml version="1.0" encoding="utf-8"?>



    谢谢joshua和总监mrshelly。



  • 嗯... 标准化模块开发...

    不推荐 直接在 xml view 中使用中文.
    推荐使用翻译来做多语言...



  • 两种方法:1.在项目启动文件中添加一下代码:
    [code]import sys
    reload(sys)
    sys.setdefaultencoding('utf8') [/code]
    2.在环境的sitecustomize.py文件中添加以上代码。


登录后回复
 

与 Odoo 中文社区 的连接断开,我们正在尝试重连,请耐心等待