odoo,如何创建正确的 xpath 表达式

发布于 2025-01-16 11:45:34 字数 1137 浏览 1 评论 0原文

我正在做 odoo 入门教程。我需要创建一个 xpath 表达式。我需要继承 base.view_users_form 视图并添加页面来显示属性列表。 该页面应该位于首选项页面之后,因此我创建了这个表达式。

<record id="inherited_res_user_view_form" model="ir.ui.view">
    <field name="name">res.users.extended.form</field>
    <field name="model">res.users</field>
    <field name="inherit_id" ref="base.view_users_form"/>
    <field name="arch" type="xml">
        <xpath expr="//page[@name='preferences']" position="after">
            <field name="property_ids"/>
        </xpath>
    </field>
</record>

和错误:

Element '<xpath expr="//page[@name='preferences']">' cannot be located in parent view

所以我知道我的表达不正确,但我不知道它应该是什么。

我也不知道怎么才能查到。我阅读一些关于它是如何工作的,我想我已经足够理解了。但我认为我需要查看 base.view_users_form 的源代码来查找它们如何命名其元素,以便我可以正确使用 xpath。但我也找不到源代码。

I'm doing the odoo getting started tutorial. And I need to create a xpath expression. I need to inherit the base.view_users_form view and add page to display a list of properties.
This page should go after the preferences page, so I created this expresssion.

<record id="inherited_res_user_view_form" model="ir.ui.view">
    <field name="name">res.users.extended.form</field>
    <field name="model">res.users</field>
    <field name="inherit_id" ref="base.view_users_form"/>
    <field name="arch" type="xml">
        <xpath expr="//page[@name='preferences']" position="after">
            <field name="property_ids"/>
        </xpath>
    </field>
</record>

and the error:

Element '<xpath expr="//page[@name='preferences']">' cannot be located in parent view

So I know my expression is incorrect, but I dont know what it should be.

I also don't know how I can find out. I read a bit about how it works, and I think I understand sufficiently. But I think I need to see the source code of base.view_users_form to find how they name their elements so that I can properly use xpath. But I can't find the source code also.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮光沉寂 2025-01-23 11:45:34

如果您仔细查看 view_users_form< /a> 代码,您将看到该页面名为 references 而不是 preferences

尝试以下 XPath:

<xpath expr="//page[@name='references']" position="after">
    <page string="Properties" name="property_ids">
        <field name="property_ids"/>
    </page>
</xpath>

If you look carefully in the view_users_form code, you will see that the page is named references and not preferences.

Try the following XPath:

<xpath expr="//page[@name='references']" position="after">
    <page string="Properties" name="property_ids">
        <field name="property_ids"/>
    </page>
</xpath>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文