【问题标题】:WARNING Error-prone use of @class警告使用@class 容易出错
【发布时间】:2018-04-15 23:19:23
【问题描述】:
> 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

谁能解释我为什么会收到此警告。仅在 2 个地方使用课程。

<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"/>

【问题讨论】:

  • 尝试使用位置属性,例如&lt;xpath expr="/div/div[2]/div[@t-if='o.name']" position="replace"/&gt;

标签: openerp odoo-8 odoo-9 odoo-10


【解决方案1】:

你现在可以使用 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"/>

【讨论】:

  • 虽然它在 Odoo 中工作,但它似乎不是标准的 XPath 功能。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多