odoo继承没有名称或id的视图元素

发布于 2025-01-17 08:00:12 字数 3043 浏览 1 评论 0原文

在 odoo 中,我尝试更改招聘表单,但某些结构元素没有名称或 ID。当我更改这些元素时,它最初工作正常,但当我升级数据库时,由于某种原因,xml 的呈现更加严格,并给出 ParseError。

招聘表格:

                <sheet>
                    <div class="oe_button_box" name="button_box"/>
                    <div class="oe_title">
                        <label for="name" class="oe_edit_only"/>
                        <h1><field name="name" placeholder="e.g. Sales Manager"/></h1>
                    </div>
                    <notebook> 
                        <page string="Job Description">
                            <div attrs="{'invisible': [('state', '!=', 'recruit')]}">
                                <label for="description"/>
                                <field name="description" type="html"/>
                            </div>
                        </page>
                        <page name="description_page" string="Description">
                          <field name="description" type="html"/>
                          <div class="d-none oe_clear"/>
                        </page>
                        <page string="Recruitment">
                            <group>
                                <group name="recruitment">
                                    <field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
                                    <field name="department_id"/>
                                </group>
                                <group>
                                    <field name="no_of_recruitment"/>
                                </group>
                            </group>
                        </page>
                    </notebook>
                </sheet>

如您所见;工作表、笔记本、页面和组大多没有名称。字符串属性也不足以用 xpath 中的表达式进行修改。所以感觉我只是被这个框架困住了。

我尝试的方法:

        <xpath expr="//sheet/notebook" position="replace">
            <notebook> 
                <page name="description_page" string="Description">
                    <field name="description" type="html"/>
                    <div class="d-none oe_clear"/>
                </page>
                <page string="Recruitment">
                    <group>
                        <group name="recruitment">
                            <field name="branch_concept" />
                            <field name="branch" />
                            <field name="department_id" />
                        </group>
                        <group>
                            <field name="no_of_recruitment"/>
                        </group>
                    </group>
                </page>
            </notebook>
            </xpath>

这一直有效,直到我进行数据库升级,然后我得到一个 parseError 。 有人知道我可以使用自己的结构吗?

In odoo I try to change the recruitement form, but some of the stuctural elements dont have a name or id. When I change those elements it works fine initially, but when I upgrade the database then the rendering of the xml is stricter for some reason and gives an ParseError.

The recruitement form:

                <sheet>
                    <div class="oe_button_box" name="button_box"/>
                    <div class="oe_title">
                        <label for="name" class="oe_edit_only"/>
                        <h1><field name="name" placeholder="e.g. Sales Manager"/></h1>
                    </div>
                    <notebook> 
                        <page string="Job Description">
                            <div attrs="{'invisible': [('state', '!=', 'recruit')]}">
                                <label for="description"/>
                                <field name="description" type="html"/>
                            </div>
                        </page>
                        <page name="description_page" string="Description">
                          <field name="description" type="html"/>
                          <div class="d-none oe_clear"/>
                        </page>
                        <page string="Recruitment">
                            <group>
                                <group name="recruitment">
                                    <field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
                                    <field name="department_id"/>
                                </group>
                                <group>
                                    <field name="no_of_recruitment"/>
                                </group>
                            </group>
                        </page>
                    </notebook>
                </sheet>

As you can see; the sheet, notebook, pages and groups mostly dont have a name. The string attribute is also not sufficient to modify with a expression in xpath. So it feels like I'm just stuck with this framework.

What I try:

        <xpath expr="//sheet/notebook" position="replace">
            <notebook> 
                <page name="description_page" string="Description">
                    <field name="description" type="html"/>
                    <div class="d-none oe_clear"/>
                </page>
                <page string="Recruitment">
                    <group>
                        <group name="recruitment">
                            <field name="branch_concept" />
                            <field name="branch" />
                            <field name="department_id" />
                        </group>
                        <group>
                            <field name="no_of_recruitment"/>
                        </group>
                    </group>
                </page>
            </notebook>
            </xpath>

And this works until I do a db upgrade, then I get a parseError.
Does anybody know I can use my own structure?

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

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

发布评论

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

评论(2

書生途 2025-01-24 08:00:12

使用父级

expr="//field[@name='some_field']/parent::page"

use parent

expr="//field[@name='some_field']/parent::page"
無心 2025-01-24 08:00:12

In the xpath expression you use //<some_node> to 'Selects nodes in the document from the current node that match the selection no matter where they are'. You can also use /<some_node>/<some_other_node> to locate a specific element.
for example /form/sheet/notebook/page[1]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文