首页 > 解决方案 > 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>   

此代码适用于更少的记录打印。但是当没有记录增加时,我的系统挂起并发生上述错误。请建议如何解决它

标签: pythonxmlodooodoo-10qweb

解决方案


发生内存错误意味着您的程序以某种方式创建了太多对象。

请优化您的 python 代码,您的变量包含太多无法处理的数据。

  • 另一种解决方案是在您的系统(32 位或 64 位)上,但我个人认为您需要优化您的 python 代码。

推荐阅读