Reputation: 891
In Odoo 9, I'm trying to inherit the purchase order form view (file: addons/purchase/purchase_view.xml, record: <record id="purchase_order_form" model="ir.ui.view">
). What I need to do is, just edit an attribute of one page
tag. I tried to select the desired page by using xpath, but it's not working fine.
Parent View Structure
<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 & Invoices">
</page>
</notebook>
In my view file, I used the following code to select the <page string="Deliveries & Invoices">
and this is not working as expected.
<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>
Thanks in advance.
Upvotes: 0
Views: 2216
Reputation: 11
<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>
Upvotes: 1