4

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

我得到了错误

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>

这是我的报告.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。非常感谢您的帮助。

4

1 回答 1

3

确保在这里

_template = 'stock.report_shortage_xls'

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

有关更多信息,您应该参考我们关于Qweb 报告的博客。

于 2015-08-21T04:18:46.283 回答