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

标签 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>

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

最佳答案

确保在这里

_template = 'stock.report_shortage_xls'

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

如需更多信息,请参阅我们的博客 Qweb Report .

关于xls - QWebException : "' NoneType' object is not callable"while evaluating 'has_shortage_so_lines(data)==True' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32125443/

相关文章:

c# - 创建没有互操作性和模板(带或不带行和列跨度)的 Excel

php - 使用PHP为一个类制作文件和目录

javascript - 添加另一个元素到模型列表 [odoo-8] pos javascript

widget - 如何使用 float_time 小部件在 Qweb Reports 中打印时间字段(声明为 float )?

html - 如何使用 HTML CSS 将图章(cachet)添加到报价中

java - 使用 POI 写入 xls 以获取大量数据,并根据需要创建新工作簿

java - 将 CSV 文件转换为 XLS 时出现问题

upgrade - 将 odoo 8 升级到 odoo 9 时遇到问题

python - 类型错误 : unhashable type: 'list' | Porting Odoo v8 to Odoo 12

javascript - 如何管理 QWEB 报告中的空间