转载地址:http://www.khcloud.net:4082/?thread-37.htm


昨天想安装一下odoo官方的blog模块,安装过程都正常,但跳转到blog页面时报错:

1
2
3
4
5
Error to render compiling AST
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4 in position 1: invalid continuation byte
Template: website_blog.blog_post_short
Path: /templates/t/t/div[3]/div/div[2]/section[5]/ul/t/t/t[2]/li/a/t
Node: <t t-esc="months['month']"/>

经查看源代码发现是在生成nav_list时,生成按月份归档目录时,生成月份使用了strftime("%B")方式,按正常是应该生成xx月,而跟踪调试发现生成的是乱码,进而在模板中解析时失败。改成strftime("%b")也同样失败。最后,改成如下形式,问题解决:

controllers/main.py 第34行:

1
group['month'= self._to_date(start).strftime("%m")+u"月"

比较好的方式应该是自己做个补丁模块,但怕麻烦,直接就在原模块上Hack了。


另外,原模块生成的归档目录,年份只有数字,没有“年”字,也可以在这里加上。