Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how to add fields in inherited notebook/page/field

By
supreeth
on 5/23/16, 11:55 PM 549 views

hi all,

I have inherited 'sales order' from 'sales' module.

I need to add two extra fields inside 'Order Lines' tab.

.py

class SalesOrderInherit(models.Model):
_inherit = "sale.order"
type = fields.Selection([('appointment', 'Appointment'), ('walkin', 'Walk-In')], string="Type")

I need to add type field inside 'Order Lines' tab.

Which table should i inherit?

How to write <xpath> to add above field.

5

Jignesh Mehta

--Jignesh Mehta--
2087
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 5/24/16, 2:19 AM

Hello Supreeth,


If you want to add in the sale.order then inherit sale.order model. If you want to add in lines then inherit sale.order.line.


Try this x-path for your field in the sale order inside the Order lines tab.

Xml :-

<record id="inherit_sale_order" model="ir.ui.view">

    <field name="name">inherit.sale.order.form.view</field>

    <field name="model">sale.order</field>

    <field name="inherit_id" ref="sale.view_order_form"/>

    <field name="arch" type="xml">

        <xpath expr="/form/sheet/notebook/page[1]/field[@name='note']" position="after">

            <group>

                <field name="type"/>

            </group>

        </xpath>

    </field>

</record>


Hope it works for you.

Thanks,

@Jignesh thank for reply. But it is nor working, Error is: ParseError: "Invalid view definition Error details: Element '<xpath expr="/form/sheet[1]/field[@name='product_id']">' cannot be located in parent view

supreeth
on 5/24/16, 2:31 AM

Hello Supreeth, See my updated anwer.

Jignesh Mehta
on 5/24/16, 2:33 AM

Thank you Jignesh

supreeth
on 5/24/16, 3:03 AM
0
supreeth
On 5/24/16, 2:54 AM

Hi, 

Got Solution:

<record id="inherit_sale_order_line" model="ir.ui.view">
<field name="name">inherit.sale.order.line.form.view</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="priority" eval="50" />
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/tree/field[2]" position="after">
<field name="type"/>
</xpath>
</field>
</record>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/23/16, 11:55 PM
Seen: 549 times
Last updated: 5/24/16, 6:06 AM