场景描述:
恢复Odoo数据后,抛出错误导致无法进入页面
2019-11-21 05:08:49,941 18 INFO aeo odoo.addons.base.ir.ir_attachment: _read_file reading /var/lib/odoo/filestore/aeo/57/576746a590a5ec2384a9428a907bc44e9117ee1e Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/odoo/addons/base/ir/ir_attachment.py", line 100, in _file_read r = open(full_path,'rb').read().encode('base64') IOError: [Errno 2] No such file or directory: u'/var/lib/odoo/filestore/aeo/57/576746a590a5ec2384a9428a907bc44e9117ee1e' 2019-11-21 05:08:49,943 18 INFO aeo odoo.addons.base.ir.ir_attachment: _read_file reading /var/lib/odoo/filestore/aeo/54/549f82ae56b7397db7fcd8ca1a179494b0cfda03 Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/odoo/addons/base/ir/ir_attachment.py", line 100, in _file_read r = open(full_path,'rb').read().encode('base64') IOError: [Errno 2] No such file or directory: u'/var/lib/odoo/filestore/aeo/54/549f82ae56b7397db7fcd8ca1a179494b0cfda03'
原因分析:
原来的环境,附加等文件存放在本地,还原到新环境后,数据库中记录了相应的附件信息,但实际上本地没有相应文件,导致出现附件找不到的异常。
解决方法:
--- 查找库中遗留的附件记录信息 select id,res_model,res_name,db_datas,file_size from ir_attachment where url LIKE '/web/content/%'; --- 将它们删除 DELETE FROM ir_attachment WHERE url LIKE '/web/content/%';
重启odoo服务,加载一下。
参考:https://jalena.bcsytv.com/archives/2022