我需要在 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/