警告@class容易出错

Cha*_*n33 4 openerp odoo-8 odoo-9 odoo-10

> 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
Run Code Online (Sandbox Code Playgroud)

有人可以解释一下我为什么收到此警告。仅在2个地方使用课程。

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

<xpath expr="//div[@class='row mt32 mb32']/div[@t-if='o.name']" position="replace"/>
Run Code Online (Sandbox Code Playgroud)

Tan*_*han 9

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

  1. 对于继承路径中的一个类:

xpath expr =“ // div [hasclass('dropdown')]” position =“ replace”>

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

xpath expr =“ // div [hasclass('dropdown','btn-group','dropdown_sorty_by')]” position =“ replace”>

在您的情况下,应为:

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