python - Qweb 报告:渲染编译 AST 时出错,内存错误
问题描述
在打印自定义 qweb 报告时,我在 odoo 10 中遇到以下错误
Error to render compiling AST
MemoryError:
Template: report.html_container
Path: /templates/t/t[2]/t
Node: <t t-raw="0"/>
我正在向 xml.my 代码发送 2 个列表和 1 个字典
<t t-foreach="qlty" t-as="q">
<t t-foreach="qlty_des" t-as="qld">
<t t-foreach="val" t-as="prd">
<tr style="border:1px solid black;">
<t t-if="prd['quality'] == q">
<t t-if="prd['quality'] == qld[0]">
<t t-if="prd['design'] == qld[1]">
<td width="16%" class="text-center">
<span t-esc="prd['size']" />
</td>
<td width="16%" class="text-center">
<span t-esc="prd['bs_col']" />
</td>
<td width="16%" class="text-center">
<span t-esc="prd['brd_col']" />
</td>
<td width="15%" class="text-center">
<span t-esc="prd['quantity']" />
<t t-set="quantity" t-value="quantity + prd['quantity']" />
/td>
<td width="15%" class="text-center">
<span t-esc="prd['area']" />
<t t-set="area" t-value="area + prd['area']" />
</td>
</t><!-- end of "prd['design'] == qld[1]-->
</t><!-- end of "prd['quality'] == qld[0]-->
</t> <!-- end of prd['quality'] == q"-->
</tr>
</t>
</t>
<t t-set="ql_count" t-value="0"/>
</t>
此代码适用于更少的记录打印。但是当没有记录增加时,我的系统挂起并发生上述错误。请建议如何解决它
解决方案
发生内存错误意味着您的程序以某种方式创建了太多对象。
请优化您的 python 代码,您的变量包含太多无法处理的数据。
- 另一种解决方案是在您的系统(32 位或 64 位)上,但我个人认为您需要优化您的 python 代码。
推荐阅读
- reactjs - 三元运算符:期望一个赋值或函数调用,而是看到一个表达式
- android - 线性布局未显示在回收站视图下方
- powershell - Powershell - Invoke-Command 脚本块中的“复制项目”命令
- linux - 登录tryton和主机问题
- javascript - 错误 webdriver:请求因错误而失败:在 TCPConnectWrap.afterConnect [as oncomplete] 处连接 ECONNREFUSED 127.0.0.1:4444 (net.js:1107:14)
- javascript - 检查是否使用 javascript 连接了音频和视频设备
- javascript - 如何在生成的数字输入字段中获取数组属性值
- docker - 从企业局域网通过 DNS 名称访问 Docker 容器
- laravel - 选择字段更改时,Laravel Backpack 通过 ajax 更新数据表
- java - 为什么使用 iText 7.1.11 在某些 PDF 文档中看不到数字签名?