xpath - 如何在 Odoo 上找到 XPath?

标签 xpath odoo

我需要在 Odoo 9 上找到正确的产品 ID 的 XPath。我已经尝试过这个,但它提示“字符串”有一些问题。

错误详细信息:

View inheritance may not use attribute 'string' as a selector.

代码:

 <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='product_id']" position="before">
     <field name="image_small" widget="image"/>
 </xpath>

最佳答案

在 odoo v9 中,不允许在 xpath 中使用字符串作为选择器。 因此,在 xpath 中使用 name 作为选择器是一个很好的做法。

您应该尝试以下操作:

<xpath expr="//page/field[@name='order_line']/form/group/group/field[@name='product_id']" position="before">
    <field name="image_small" widget="image"/>
</xpath>

或者你也可以这样写xpath,

<xpath expr="//field[@name='order_line']//form//field[@name='product_id']" position="before">
    <field name="image_small" widget="image"/>
</xpath>

关于xpath - 如何在 Odoo 上找到 XPath?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39035999/

相关文章:

odoo - 如何在 odoo9 中使用 default_get 覆盖字段默认值?

qt - 如何使 wkhtmltopdf 在 Debian 9 "Stretch"上的 Odoo v10 中工作?

c# - xpath 查询在网页中搜索字符串

c# - 如何从 XML 元素中获取子元素和孙元素?

java - 如何在java selenium中通过xpath识别文本为Sign in with Google的元素

odoo - 异常 :bus. 总线在 Odoo 中不可用

python - 如何通过模块向many2one添加字段

java - GetText() 说明 - xpath 不返回值

php - 遍历DOM向后查找ID

python - 如何在onchange方法中复制One2many字段并修改它?