Xpath选择在Odoo 9中不起作用

时间:2016-04-05 10:49:03

标签: xml xpath openerp odoo-9 qweb

在Odoo 9中,我正在尝试继承采购订单表单视图(文件:addons / purchase / purchase_view.xml,记录:<record id="purchase_order_form" model="ir.ui.view">)。我需要做的是,只需编辑一个page标记的属性。我尝试使用xpath选择所需的页面,但它没有正常工作。

父视图结构

<notebook>
    <page string="Products">
        ......
        ......
        <notebook>
        <page string="Notes">
            <field name="name"/>
        </page><page string="Invoices and Incoming Shipments">
            <field name="invoice_lines"/>
            <field name="move_ids"/>
        </page>
        </notebook>
        ......
        ......
    </page>
    <page string="Deliveries &amp; Invoices">


    </page>
</notebook>

在我的视图文件中,我使用以下代码选择<page string="Deliveries &amp; Invoices">,但这不能按预期工作。

<record model="ir.ui.view" id="purchase_order_type_form_view_inherit">
    <field name="name">purchase.order.form.inherit</field>
    <field name="model">purchase.order</field>
    <field name="inherit_id" ref="purchase.purchase_order_form"/>
    <field name="priority">10000</field>
    <field name="arch" type="xml">
        <xpath expr="//notebook/page[2]" position="attributes">
            <attribute name="groups">custom_module.manager</attribute>
        </xpath>
    </field>
</record>

提前致谢。

1 个答案:

答案 0 :(得分:0)

<record model="ir.ui.view" id="purchase_order_type_form_view_inherit">
        <field name="name">purchase.order.form.inherit</field>
        <field name="model">hr_employee</field>
        <field name="inherit_id" ref="purchase.purchase_order_form"/>
        <field name="priority">10000</field>
        <field name="arch" type="xml">
            <xpath expr="//form/sheet/notebook/" position="after">
                <page>
                    <group>
                            <group colspan="4" col="4">

                                <label for="employment_ids" colspan="4" />
                                <field name="employment_ids" colspan="4" nolabel="1">
                                    <form string="Employee Employment">
                                        <field name="organization" />
                                        <field name="job_title" />
                                        <field name="entered_date" />
                                        <field name="resigned_date" />
                                        <field name="resigned_reason" />
                                        <field name="responsibility" />
                                        <field name="wage" />
                                    </form>
                                    <tree string="Employee Employment" editable="bottom">
                                        <field name="organization" />
                                        <field name="job_title" />
                                        <field name="entered_date" />
                                        <field name="resigned_date" />
                                        <field name="resigned_reason" />
                                        <field name="responsibility" />
                                        <field name="wage" />
                                    </tree>
                                </field>
                            </group>
                    </group>
                </page>
            </xpath>
        </field>
    </record>