内部服务器错误ir.attachment

时间:2015-10-08 10:06:40

标签: python openerp

我正在使用ir.attachment模块。 所以我正在创建自己的文档,然后通过这种方式自动将其添加到附件中:

filename="/opt/file.txt"
files = open(filename,'rb').read()
ir_values={

'name':"image_name",
'index_content': files,
'datas_fname': "image_name",
'type':'binary',
# 'partner_id':ids[0],
'res_model':'declaration.cnss',
'res_id':ids[0],
 }
self.pool.get('ir.attachment').create(cr,uid,ir_values,context=context)

而且,不幸的是我有这个错误:

  Internal Server Error

 {"message": "OpenERP WebClient Error", "code": 300, "data": {"debug":   "Client Traceback (most recent call last):\n File \"/opt   /openerp/v7/addons/web/http.py\", line 285, in dispatch\n r = method(self,    **self.params)\n File \"/opt/openerp/v7/addons/web/controllers/main.py\", line 1286, in saveas\n filecontent = base64.b64decode(res.get(field, ''))\n File \"/usr/lib/python2.7/base64.py\", line 73, in b64decode\n return binascii.a2b_base64(s)\nTypeError: must be string or buffer, not bool\n", "type": "client_exception"}}

任何人都可以帮忙:/

问候。

1 个答案:

答案 0 :(得分:0)

你可能有旧版本的 werkzeug 我们可能会在第299行看到addons/web/http.py在你的情况下,错误会从他们那里抛出消息。

我们可能会从下面的命令看到系统 werkzeug 版本。

pip show werkzeug 

如果您的版本较旧,请尝试使用以下命令升级 0.9.6

pip install Werkzeug==0.9.6

有关Werkzeug的更多信息,请访问Werkzeug Installtion