我正在尝试使用Odoo
打印我正在构建的自定义模块的报告,但是当我尝试打印时出现以下错误:
File "/opt/odoo/openerp/service/report.py", line 93, in go
result, format = openerp.report.render_report(cr, uid, ids, object, datas, context)
File "/opt/odoo/openerp/report/__init__.py", line 40, in render_report
return registry['ir.actions.report.xml'].render_report(cr, uid, ids, name, data, context)
File "/opt/odoo/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/addons/base/ir/ir_actions.py", line 155, in render_report
return new_report.create(cr, uid, res_ids, data, context)
File "/opt/odoo/addons/report_webkit/webkit_report.py", line 376, in create
result = self.create_source_pdf(cursor, uid, ids, data, report_xml, context)
File "/opt/odoo/openerp/report/report_sxw.py", line 461, in create_source_pdf
return self.create_single_pdf(cr, uid, ids, data, report_xml, context)
File "/opt/odoo/addons/report_webkit/webkit_report.py", line 334, in create_single_pdf
head_mako_tpl = mako_template(header)
File "/opt/odoo/addons/report_webkit/webkit_report.py", line 88, in mako_template
return mako_template_env.from_string(text)
File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 769, in from_string
return cls.from_code(self, self.compile(source), globals, None)
File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 493, in compile
self.handle_exception(exc_info, source_hint=source)
File "<unknown>", line 24, in template
TemplateAssertionError: no filter named 'n'
我搜索了很多,但是找不到任何关于如何解决这个问题的线索。
我正在使用webkit
报告。这是我的.mako
文件。
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
Testing
</body>
</html>
这是我从.py
文件
report_sxw.report_sxw('report.hotel.webkit',
'hotel.webkit',
'addons/hotel_webkit/report/report_hotel.mako',
parser=report_webkit_html)
最后是XML
电话
<report id="sim.report_sim_hotel"
name="hotel.webkit"
auto="False"
model="sim.resumen_wizard"
file="hotel_webkit/report/report_hotel.mako"
string="Hotel Report Test"
webkit_header="base_headers_webkit.base_reports_portrait_header"
report_type="webkit"/>
任何关于该错误意味着什么以及我还能测试什么以使报告有效的任何线索都将受到赞赏。
由于
答案 0 :(得分:2)
我刚刚为发票解决了这个问题。
Odoo在v7中从Mako切换到了v8中的Jinja2,并使用了#34;模拟&#34; Mako符号大多数的东西像以前一样工作。内联Python代码没有,这个&#34; n&#34;过滤器没有。
你必须从Mako&#34; | n&#34;到Jinja2&#34; | safe&#34; (此过滤器表示&#34;不要逃避&#34; - 通常应用于返回HTML的内容。)
如果您没有在模板中使用它,它可能在您的基本标题中!
我们有一条线
${_debug or ''|n}
应该阅读
${_debug or ''|safe}
为Odoo。