How to inherit a specific view in our own module? ODOO

Good morning, I would like to inherit some views from ODOO views. so that I can use it in my module. can someone please explain to me what are the possible ways to it?

Thanks in advance.!

+4
source share
2 answers

View inheritance

Instead of modifying existing views (by overwriting them), Odoo provides view inheritance when child views of the "extension" are applied on top of the root views and can add or remove content from their parent.

, inherit_id, xpath, :

<!-- improved idea categories list -->
<record id="idea_category_list2" model="ir.ui.view">
    <field name="name">id.category.list2</field>
    <field name="model">idea.category</field>
    <field name="inherit_id" ref="id_category_list"/>
    <field name="arch" type="xml">
        <!-- find field description and add the field
             idea_ids after it -->
        <xpath expr="//field[@name='description']" position="after">
          <field name="idea_ids" string="Number of ideas"/>
        </xpath>
    </field>
</record>

   XPath, . , ,

Operation to apply to the matched element:

inside
    appends xpath body at the end of the matched element
replace
    replaces the matched element by the xpath body
before
    inserts the xpath body as a sibling before the matched element
after
    inserts the xpaths body as a sibling after the matched element
attributes
    alters the attributes of the matched element using special attribute elements in the xpath body

position , . .

<xpath expr="//field[@name='description']" position="after">
    <field name="idea_ids" />
</xpath>

<field name="description" position="after">
    <field name="idea_ids" />
</field>

.

+6

. , purchase.order

class purchase_order(osv.osv):
_inherit="purchase.order"

// , ,

,

<record id="purchase_order_advance_invoice_inherit_form" model="ir.ui.view">
<field name="name">purchase.order.advance.invoice.inherit.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" **ref="purchase.purchase_order_form"**/>

// , , , rest

+1

Source: https://habr.com/ru/post/1611536/


All Articles