QWebException:"' NoneType'对象不可调用"在评估' has_shortage_so_lines(数据)== True'

时间:2015-08-20 18:12:34

标签: xls odoo-8 qweb

我在here找到了另一个问题。但没有答案。

我收到了错误

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。非常感谢你的帮助。

1 个答案:

答案 0 :(得分:3)

请确保

_template = 'stock.report_shortage_xls'

它必须是带有报告名称的模块名称,您已经为sale.order创建了报告,并且您已经提供了库存模块名称,在您的情况下它是否正确?

有关详细信息,请参阅我们的博客Qweb Report