2015-08-20 29 views
4

我在here处发现了另一个问题。但没有答案。QWebException:在评估'has_shortage_so_lines(data)== True'时''NoneType'对象不可调用'

我得到了错误

QWebException: "'NoneType' object is not callable" while evaluating 'has_shortage_so_lines(data)==True' 

这是我report_view.xml

<?xml version="1.0" encoding="utf-8"?> 
<openerp> 
    <data> 
    <!-- External Consumption Report --> 
    <!-- Landscape Paper Format--> 
    <record id="paperformat_LetterLandscape" model="report.paperformat"> 
     <field name="name">US Letter Landscape</field> 
     <field name="default" eval="True"/> 
     <field name="format">Letter</field> 
     <field name="page_height">0</field> 
     <field name="page_width">0</field> 
     <field name="orientation">Landscape</field> 
     <field name="margin_top">15</field> 
     <field name="margin_bottom">15</field> 
     <field name="margin_left">2</field> 
     <field name="margin_right">2</field> 
     <field name="header_line" eval="False"/> 
     <field name="header_spacing">7</field> 
     <field name="dpi">100</field> 
    </record> 
    <!--Report XLS--> 
    <report 
     id="action_report_shortage_xls" 
     model="sale.order" 
     string="Shortage Report" 
     report_type="qweb-html" 
     name="sale.report_shortage_xls" 
     file="sale.report_shortage_xls"/> 
    <!--Paper Format to shortage report--> 
    <record id="action_report_shortage_xls" model="ir.actions.report.xml"> 
     <field name="paperformat_id" ref="stock.paperformat_LetterLandscape"/> 
    </record> 
    </data> 
</openerp> 

这是我report_xls.xml

<?xml version="1.0" encoding="utf-8"?> 
<openerp> 
    <data> 
    <!-- Translatable template --> 
    <template id="report_shortage_xls"> 
     <div class="workbook"> 
     <div class="worksheet" name="Shortage Report"> 
      <table> 
      <tbody> 
       <tr> 
       <td easyfx="font: height 200;align: horizontal left,vert center">Printed On :</td> 
       <td><span t-usertime="%d-%m-%Y %H:%M" /></td> 
       </tr> 
       <tr> 
       </tr> 
      </tbody> 
      </table> 
      <table> 
      <thead> 
      <tr> 
       <th colspan="17" easyfx="font: height 400, bold on;align: horizontal center,vert center">Shortage Report</th> 
      </tr> 
      <!--<tr> 
       <th> 
       <span t-esc="has_shortage_so_lines(o.id)"/> 
       </th> 
      </tr>--> 
      </thead> 
     </table> 
     <t t-if="has_shortage_so_lines(data)==True"> 
      <table> 
      <thead> 
       <tr> 
       <th easyfx="font:height 200, bold on;align: horizontal center,vert center;">Date</th> 
       <th easyfx="font:height 200, bold on;align: horizontal center,vert center;">SO No</th> 
       <th easyfx="font:height 200, bold on;align: horizontal center,vert center;">Customer Ref No</th> 
       </tr> 
      </thead> 
      </table> 
     </t> 
     </div> 
    </div> 
    </template> 
    <!-- Main template --> 
    <template id="xls_report_shortage"> 
    <t t-call="report.html_container"> 
     <t t-foreach="doc_ids" t-as="doc_id"> 
     <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_shortage_xls')"/> 
     </t> 
     </t> 
    </template> 
    </data> 
</openerp> 

这是我report.py

class ShortageReport(report_sxw.rml_parse): 
    def __init__(self, cr, uid, name, context): 
     super(ShortageReport, self).__init__(cr, uid, name, context=context) 
     self.localcontext.update({ 
      'get_date_from': self.get_date_from, 
      'get_date_to': self.get_date_to, 
      'has_shortage_so_lines': self.has_shortage_so_lines, 
      'get_shortage_lines': self.get_shortage_lines, 
     }) 
    def has_shortage_so_lines(self, order_id): 
     _logger.info("sale order id >>> : %r", order_id) 
     lines_obj = self.get_shortage_so_lines(order_id) 
     if lines_obj: 
      return True 
     return False 

class report_shortage_xls(osv.AbstractModel):#(models.AbstractModel): 
    _name = 'report.stock.report_shortage_xls' 
    _inherit = 'report.abstract_report' 
    _template = 'stock.report_shortage_xls' 
    _wrapped_report_class = ShortageReport 

有没有办法从odoo中导出xls。非常感谢你的帮助。

回答

3

请确保此处

_template = 'stock.report_shortage_xls' 

它必须是模块的名称与报告的名称,你已经创造了sale.order报告,你给股票模块名称,它是正确的,你的情况?我们的博客Qweb Report

相关问题