代码之家  ›  专栏  ›  技术社区  ›  Chaban33

警告:使用@class时容易出错

  •  11
  • Chaban33  · 技术社区  · 8 年前
    > WARNING 11_test1 odoo.addons.base.ir.ir_ui_view: Error-prone use of
    > @class in view report_invoice_document
    > (account_invoice_report.report_invoice_document): use the
    > hasclass(*classes) function to filter elements by their classes
    

    有人能解释一下为什么我会收到这个警告吗。仅在两个位置使用类。

    <td class="text-right">
    <span t-esc="', '.join(map(lambda x: (x.description or x.name), l.invoice_line_tax_ids))"/>
      </td>
    

    <xpath expr="//div[@class='row mt32 mb32']/div[@t-if='o.name']" position="replace"/>
    
    1 回复  |  直到 8 年前
        1
  •  24
  •   Tanzil Khan    8 年前

    现在可以使用hasclass()。示例-

    1. 如果继承路径中有一个类:

    1. 如果继承路径中有多个类:

    xpath expr=“//div[hasclass('dropdown','btn-group','dropdown\u sorty\u by')”position=“replace”>

    在您的情况下,它应该是:

    <xpath expr="//div[hasclass('row','mt32','mb32')]/div[@t-if='o.name']" position="replace"/>